Skip to content
This repository has been archived by the owner on Jun 14, 2020. It is now read-only.

Commit

Permalink
Ensure 'this' context is set for Deferred content.ajax conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
Craga89 committed Apr 6, 2013
1 parent 14f20e8 commit 13c9fbc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/intro.js
Expand Up @@ -90,7 +90,7 @@
function sanitizeOptions(opts) {
var invalid = function(a) { return a === NULL || !$.isPlainObject(a); },
invalidContent = function(c) { return !$.isFunction(c) && ((!c && !c.attr) || c.length < 1 || ('object' === typeof c && !c.jquery && !c.then)); },
once;
ajax, once;

if(!opts || 'object' !== typeof opts) { return FALSE; }

Expand All @@ -110,9 +110,14 @@
// DEPRECATED - Old content.ajax plugin functionality
// Converts it into the proper Deferred syntax
if('ajax' in opts.content) {
once = opts.content.ajax.once !== FALSE;
ajax = opts.content.ajax;
once = ajax && ajax.once !== FALSE;
opts.content.ajax = null;

opts.content.text = function(event, api) {
var deferred = $.ajax(opts.content.ajax)
var deferred = $.ajax(
$.extend({}, opts.content.ajax, { context: api })
)
.then(function(content) {
if(once) { api.set('content.text', content); }
return content;
Expand Down

0 comments on commit 13c9fbc

Please sign in to comment.