Created
January 31, 2011 23:29
-
-
Save ajshort/805059 to your computer and use it in GitHub Desktop.
Fixes callback handlers not being passed the correct context.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Index: javascript/core/jquery.ondemand.js | |
| =================================================================== | |
| --- javascript/core/jquery.ondemand.js (revision 115901) | |
| +++ javascript/core/jquery.ondemand.js (working copy) | |
| @@ -150,12 +150,15 @@ | |
| // This replaces the usual ajax success & complete handlers. They are called after any on demand JS is loaded. | |
| var _ondemandComplete = function(xml, status) { | |
| - var status = $.httpSuccess(xml) ? 'success' : 'error'; | |
| + var status = $.httpSuccess(xml) ? 'success' : 'error'; | |
| + var context = s && s.context || $; | |
| + | |
| if(status == 'success') { | |
| var data = jQuery.httpData(xml, _dataType); | |
| - if(_success) _success(data, status); | |
| + if(_success) _success.call(context, data, status); | |
| } | |
| - if(_complete) _complete(xml, status); | |
| + | |
| + if(_complete) _complete.call(context, xml, status); | |
| } | |
| // We remove the success handler and take care of calling it outselves within _ondemandComplete |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment