Sha256: e64b28dcc4ef91f1c873e6f48f97620b60cbbae037e63e39c5c85b79c8fb50ae
Contents?: true
Size: 1020 Bytes
Versions: 2
Compression:
Stored size: 1020 Bytes
Contents
(function($) { Backbone._sync = Backbone.sync; Backbone.sync = function(method, model, options) { if (!options.noCSRF) { var beforeSend = options.beforeSend; // Set X-CSRF-Token HTTP header options.beforeSend = function(xhr) { var token = $('meta[name="csrf-token"]').attr('content'); if (token) xhr.setRequestHeader('X-CSRF-Token', token); if (beforeSend) return beforeSend.apply(this, arguments); }; } // Serialize data, optionally using paramRoot if (options.data == null && model && (method === 'create' || method === 'update' || method === 'patch')) { options.contentType = 'application/json'; data = JSON.stringify(options.attrs || model.toJSON(options)); if (model.paramRoot) { data = {}; data[model.paramRoot] = model.toJSON(options); } else { data = model.toJSON(); } options.data = JSON.stringify(data); } return Backbone._sync(method, model, options); }; })(jQuery);
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
bbr-wsm-1.1.0 | vendor/assets/javascripts/backbone_rails_sync.js |
rails-backbone-1.2.0 | vendor/assets/javascripts/backbone_rails_sync.js |