Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit 07a6c22

Browse files
committed
Merge pull request #206 from bertzzie/master
Added deleteMethod option (#205)
2 parents 2468cb0 + ce09158 commit 07a6c22

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/js/images.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
addonName = 'Images', // first char is uppercase
1010
defaults = {
1111
label: '<span class="fa fa-camera"></span>',
12+
deleteMethod: 'POST',
1213
deleteScript: 'delete.php',
1314
preview: true,
1415
captions: true,
@@ -521,7 +522,14 @@
521522

522523
Images.prototype.deleteFile = function (file) {
523524
if (this.options.deleteScript) {
524-
$.post(this.options.deleteScript, { file: file });
525+
// If deleteMethod is somehow undefined, defaults to POST
526+
var method = this.options.deleteMethod || 'POST';
527+
528+
$.ajax({
529+
url: this.options.deleteScript,
530+
type: method,
531+
data: { file: file }
532+
});
525533
}
526534
};
527535

test/images.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,9 @@ asyncTest('deleting file', function () {
313313
.append('<figure><img src="image1.jpg" alt=""></figure>'+
314314
'<figure><img src="image2.jpg" alt="" class="medium-insert-image-active"></figure>');
315315

316-
this.stub(jQuery, 'post', function () {
316+
this.stub(jQuery, 'ajax', function () {
317317
ok(1, 'ajax call created');
318-
jQuery.post.restore();
318+
jQuery.ajax.restore();
319319
start();
320320
});
321321

@@ -525,4 +525,4 @@ asyncTest('file size validation', function () {
525525
files: [{ type: 'image/jpeg', size: 1001 }]
526526
});
527527
});
528-
*/
528+
*/

0 commit comments

Comments
 (0)