简体   繁体   中英

Problem with Ajaxed Wordpress and internal # Links

I use Ajax to load the #article content from the single.php into a page template where my filterable image navigation is.

the content loads fine and the filter navigation works. but when i try to copy&paste the link into a new tab the deeplinking won't work.

i figured out that the problem is the filterable navigation that filters by adding a #foo to the url. if i remove that function/plugin everything works.

The Ajax adds an event listner to all internal links except a few which are defined hereby:

 $(document).delegate("a[href^='"+siteUrl+"']:not([href*=/wp-admin/]):not([href*=/wp-login.php]):not([href$=/feed/])", "click", function() { 
    location.hash = this.pathname; 
    return false; 
 });

i tried adding my internal links for the filter in there, but had no success with :not[(href^=#)] and similiar because i don't know the logic.

i need to exclude all links from #portfolio-filter li a

You could just add a class to all of the links you don't want to include, like:

$('#portfolio-filter li a').addClass('ignore');

and then work $('a[class!="ignore"]') into the selector.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM