mirror of
https://github.com/jashkenas/backbone.git
synced 2026-04-30 03:00:06 -04:00
Merge branch 'master' of github.com:documentcloud/backbone
This commit is contained in:
13
backbone.js
13
backbone.js
@@ -133,7 +133,7 @@
|
||||
var defaults;
|
||||
attributes || (attributes = {});
|
||||
if (defaults = this.defaults) {
|
||||
if (_.isFunction(defaults)) defaults = defaults();
|
||||
if (_.isFunction(defaults)) defaults = defaults.call(this);
|
||||
attributes = _.extend({}, defaults, attributes);
|
||||
}
|
||||
this.attributes = {};
|
||||
@@ -1035,8 +1035,7 @@
|
||||
// Default JSON-request options.
|
||||
var params = _.extend({
|
||||
type: type,
|
||||
dataType: 'json',
|
||||
processData: false
|
||||
dataType: 'json'
|
||||
}, options);
|
||||
|
||||
// Ensure that we have a URL.
|
||||
@@ -1053,7 +1052,6 @@
|
||||
// For older servers, emulate JSON by encoding the request into an HTML-form.
|
||||
if (Backbone.emulateJSON) {
|
||||
params.contentType = 'application/x-www-form-urlencoded';
|
||||
params.processData = true;
|
||||
params.data = params.data ? {model : params.data} : {};
|
||||
}
|
||||
|
||||
@@ -1069,6 +1067,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Don't process data on a non-GET request.
|
||||
if (params.type !== 'GET') {
|
||||
params.processData = false;
|
||||
}
|
||||
|
||||
// Make the request.
|
||||
return $.ajax(params);
|
||||
};
|
||||
@@ -1143,7 +1146,7 @@
|
||||
|
||||
// Helper function to escape a string for HTML rendering.
|
||||
var escapeHTML = function(string) {
|
||||
return string.replace(/&(?!\w+;|#\d+;|#x[\da-f]+;)/gi, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/');
|
||||
return string.replace(/&(?!\w+;|#\d+;|#x[\da-f]+;)/gi, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/');
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
Reference in New Issue
Block a user