app/assets/javascripts/spine/ajax.js in spine-rails-0.0.4 vs app/assets/javascripts/spine/ajax.js in spine-rails-0.0.5
- old
+ new
@@ -55,11 +55,14 @@
Base = (function() {
function Base() {}
Base.prototype.defaults = {
contentType: 'application/json',
dataType: 'json',
- processData: false
+ processData: false,
+ headers: {
+ 'X-Requested-With': 'XMLHttpRequest'
+ }
};
Base.prototype.ajax = function(params, defaults) {
return $.ajax($.extend({}, this.defaults, defaults, params));
};
Base.prototype.queue = function(callback) {
@@ -201,19 +204,21 @@
return "" + Model.host + "/" + (this.className.toLowerCase()) + "s";
}
};
Model.Ajax = {
extended: function() {
- this.change(function(record, type) {
- return record.ajax()[type]();
- });
- this.fetch(function() {
- var _ref;
- return (_ref = this.ajax()).fetch.apply(_ref, arguments);
- });
+ this.fetch(this.ajaxFetch);
+ this.change(this.ajaxChange);
this.extend(Extend);
return this.include(Include);
+ },
+ ajaxFetch: function() {
+ var _ref;
+ return (_ref = this.ajax()).fetch.apply(_ref, arguments);
+ },
+ ajaxChange: function(record, type) {
+ return record.ajax()[type]();
}
};
Model.Ajax.Methods = {
extended: function() {
this.extend(Extend);
@@ -222,6 +227,6 @@
};
Spine.Ajax = Ajax;
if (typeof module !== "undefined" && module !== null) {
module.exports = Ajax;
}
-}).call(this);
+}).call(this);
\ No newline at end of file