I am using the following code to avoid refresh of links, but I have few links using Omniauth like facebook login, google login and twitter login, so I don't want to use this script for those links. How can I remove those links from this script. It is ruby on rails app.
$(function(){
var newHash = '',
$mainContent = $("#main-content");
$(".nav").delegate("a","click",function(){
window.location.hash = $(this).attr("href");
return false;
});
$(window).bind('hashchange',function(){
newHash = window.location.hash.substring(1);
if(newHash){
$mainContent.find("#guts").fadeOut('slow',function(){
$mainContent.hide().load(newHash + " #guts",function(){
$mainContent.fadeIn('slow');
});
});
}
});
$(window).trigger("hashchange");
});
can do something like this
$(".nav").delegate("a","click",function(e){
if (this.hash ){
e.preventDefault();
window.location.hash = $(this).attr("href");
}
/* other links with no hash work normally*/
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.