Skip to content

Instantly share code, notes, and snippets.

@scottgonzalez
Created February 9, 2011 21:06
Show Gist options
  • Save scottgonzalez/819279 to your computer and use it in GitHub Desktop.
Save scottgonzalez/819279 to your computer and use it in GitHub Desktop.
$.event.special.hijax = {
setup: function() {
$.event.add( this, "click.specialHijax", function( event, data ) {
if ( event.which !== 1 || event.metaKey || event.ctrlKey ) {
return;
}
event.type = "hijax";
event.liveFired = undefined;
return jQuery.event.trigger( event, data, event.target );
});
},
teardown: function() {
jQuery.event.remove( this, ".specialHijax" );
}
};
$.fn.hijax = function( data, fn ) {
if ( !fn ) {
fn = data;
data = null;
}
this.bind( "hijax", data, fn );
};
$.attrFn.hijax = true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment