1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2024-12-26 17:59:14 +00:00
Radarr/UI/Mixins/backbone.ajax.js

29 lines
707 B
JavaScript
Raw Normal View History

2013-02-22 05:56:46 +00:00
//try to add ajax data as query string to DELETE calls.
2013-06-22 06:24:24 +00:00
'use strict';
2013-06-21 05:35:56 +00:00
define(function () {
2013-02-15 23:38:53 +00:00
2013-06-21 05:35:56 +00:00
return function () {
2013-02-15 23:38:53 +00:00
2013-06-21 05:35:56 +00:00
var original = this.ajax;
this.ajax = function () {
2013-02-15 23:38:53 +00:00
2013-06-21 05:35:56 +00:00
var xhr = arguments[0];
2013-02-15 23:38:53 +00:00
2013-06-21 05:35:56 +00:00
//check if ajax call was made with data option
if (xhr && xhr.data && xhr.type === 'DELETE') {
if (xhr.url.indexOf('?') === -1) {
xhr.url = xhr.url + '?' + $.param(xhr.data);
}
else {
xhr.url = xhr.url + '&' + $.param(xhr.data);
}
delete xhr.data;
2013-02-15 23:38:53 +00:00
}
2013-06-21 05:35:56 +00:00
return original.apply(this, arguments);
};
2013-02-15 23:38:53 +00:00
};
2013-06-21 05:35:56 +00:00
});