|
/**
* jQuery hijack plugin
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
* @author Krzysztof Kotowicz <kkotowicz at gmail dot com>
* @see http://code.google.com/p/jquery-hijack/
*/
jQuery.fn.hijack=function(afterLoadFunction){var target=this;return this.find('a:not(.nohijack)').click(function(event){if(event.isDefaultPrevented())
return;jQuery(target).load(this.href,function(){jQuery(this).hijack(afterLoadFunction);if(jQuery.isFunction(afterLoadFunction)){afterLoadFunction.call(this);}});return false;}).end().find('form:not(.nohijack)').hijackForm(target,afterLoadFunction).end();};jQuery.fn.hijackForm=function(target,afterLoadFunction){if(!jQuery.fn.ajaxForm){return this;}
return jQuery(this).ajaxForm({target:target,beforeSubmit:function(fdata,jqForm,options){if(jqForm.data('skip')){jqForm.data('skip',false);return false;}},success:function(){jQuery(target).hijack(afterLoadFunction);if(jQuery.isFunction(afterLoadFunction)){afterLoadFunction.call(target);}}});};
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am an Automation Engineer specializing in application and web development/support.