I am currently customizing a WordPress theme to load posts and pages using AJAX. I have successfully implemented this functionality with the code snippet below, but now I need to prevent the AJAX function from running when clicking on the logo that links to the home URL. Instead, I want the page to reload normally when the logo is clicked.
I believe I need to incorporate a conditional statement like "if hasClass(logo) then use default"... As someone who is new to JavaScript, I have been doing a lot of research but would greatly appreciate any guidance in the right direction. Thank you!
Here is the code snippet:
$(".home li.home").removeClass("home").addClass("current_page_item"); var $wrapperAjax = $("#wrapper-ajax"), URL = '', siteURL = "http://" + top.location.host.toString(), $internalLinks = $("a[href^='"+siteURL+"']"), hash = window.location.hash, $ajaxSpinner = $("#ajax-loader"), $el, $allLinks = $("a"); function hashizeLinks() { $("a[href^='"+siteURL+"']").each(function() { $el = $(this); if ($.browser.msie) { $el.attr("href", "#/" + this.pathname) .attr("rel", "internal"); } else { $el.attr("href", "#" + this.pathname) .attr("rel", "internal"); } }); }; hashizeLinks(); $("a[rel='internal']").live("click", function() { $ajaxSpinner.fadeIn(); $wrapperAjax.animate({ opacity: "0.1" }); $el = $(this); $(".current_page_item").removeClass("current_page_item"); $allLinks.removeClass("current_link"); URL = $el.attr("href").substring(1); URL = URL + " .entry"; $wrapperAjax.load(URL, function() { $el.addClass("current_link").parent().addClass("current_page_item"); $ajaxSpinner.fadeOut(); $wrapperAjax.animate({ opacity: "1" }); hashizeLinks(); }); }); $("#searchform").submit(function(e) { $ajaxSpinner.fadeIn(); $wrapperAjax.animate({ opacity: "0.1" }); $el = $(this); $(".current_page_item").removeClass("current_page_item"); $allLinks.removeClass("current_link"); URL = "/?s=" + $("#s").val() + " .entry"; $wrapperAjax.load(URL, function() { $ajaxSpinner.fadeOut(); $wrapperAjax.animate({ opacity: "1" }); hashizeLinks(); }); e.preventDefault(); }); if ((hash) && (hash != "#/")) { $("a[href*='"+hash+"']").trigger("click"); }