Skip to content

Commit bada3f7

Browse files
authored
Merge pull request #6 from hhz-saner/fix-js
fix
2 parents 391d683 + 80c3c48 commit bada3f7

File tree

1 file changed

+39
-35
lines changed

1 file changed

+39
-35
lines changed

resources/views/index.blade.php

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -111,23 +111,25 @@
111111
title: "Delete key ["+key+"] ?",
112112
type: "error",
113113
showCancelButton: true
114-
},
115-
function(){
116-
var params = {
117-
conn: "{{ $conn }}",
118-
key: key,
119-
_token: LA.token
120-
};
121-
122-
$.ajax({
123-
url: '{{ route('redis-key-delete') }}',
124-
type: 'DELETE',
125-
data: params,
126-
success: function(result) {
127-
toastr.success('Key '+key+' deleted');
128-
$.pjax.reload('#pjax-container');
129-
}
130-
});
114+
}).then(function (result) {
115+
if (result.value) {
116+
117+
var params = {
118+
conn: "{{ $conn }}",
119+
key: key,
120+
_token: LA.token
121+
};
122+
123+
$.ajax({
124+
url: '{{ route('redis-key-delete') }}',
125+
type: 'DELETE',
126+
data: params,
127+
success: function (result) {
128+
toastr.success('Key ' + key + ' deleted');
129+
$.pjax.reload('#pjax-container');
130+
}
131+
});
132+
}
131133
});
132134
});
133135
@@ -143,24 +145,26 @@ function(){
143145
title: "Delete selected keys ?",
144146
type: "error",
145147
showCancelButton: true
146-
},
147-
function(){
148-
149-
var params = {
150-
conn: "{{ $conn }}",
151-
key: keys,
152-
_token: LA.token
153-
};
154-
155-
$.ajax({
156-
url: '{{ route('redis-key-delete') }}',
157-
type: 'DELETE',
158-
data: params,
159-
success: function(result) {
160-
toastr.success(params.key.length+' keys deleted');
161-
$.pjax.reload('#pjax-container');
162-
}
163-
});
148+
}).then(function (result) {
149+
if (result.value) {
150+
151+
152+
var params = {
153+
conn: "{{ $conn }}",
154+
key: keys,
155+
_token: LA.token
156+
};
157+
158+
$.ajax({
159+
url: '{{ route('redis-key-delete') }}',
160+
type: 'DELETE',
161+
data: params,
162+
success: function (result) {
163+
toastr.success(params.key.length + ' keys deleted');
164+
$.pjax.reload('#pjax-container');
165+
}
166+
});
167+
}
164168
});
165169
});
166170

0 commit comments

Comments
 (0)