Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
jgt.replace.js added iUI style replacement
(function($){
if ($.jQTouch) {
$.jQTouch.addExtension(function ReplaceLoad(jQT){
function load($anchor, $replace) {
if ($anchor.hasClass('loading')) return;
$anchor.addClass('loading active');
$.get($anchor.attr('href'), function(data) {
$replace.after(data).remove();
});
}
// compatible iUI
$("a[target='_replace']").tap(function(){
var $anchor = $(this), $replace = $anchor, $parent = $anchor.parent(), parentNodeName = $parent.attr('nodeName');
if (parentNodeName=='LI') $replace = $parent;
load($anchor, $replace);
return false;
});
$("a[target='_selfnode']").tap(function(){
var $anchor = $(this);
load($anchor, $anchor);
return false;
});
$("a[target='_parentnode']").tap(function(){
var $anchor = $(this), $replace = $anchor.parent();
load($anchor, $replace);
return false;
});
});
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment