Skip to content

Instantly share code, notes, and snippets.

@scottgonzalez
Created March 8, 2011 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottgonzalez/861219 to your computer and use it in GitHub Desktop.
Save scottgonzalez/861219 to your computer and use it in GitHub Desktop.
(function( $ ) {
$( "a[data-replace]" ).live( "click", function( event ) {
var anchor = $( this ),
replace = $( "#" + anchor.attr( "data-replace" ) ),
href = anchor.attr( "href" );
replace
.trigger( "replaceSend", [ {
anchor: anchor,
href: href
} ] )
.load( href, function( response, status, xhr ) {
if ( status === "error" ) {
replace.trigger( "replaceError", [ {
xhr: xhr
} ] );
} else {
replace.trigger( "replaceSuccess" );
}
replace.trigger( "replaceComplete" );
} );
event.preventDefault();
});
})( jQuery );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment