WordPress.org

Ready to get started?Download WordPress

Forums

Advanced AJAX Page Loader
[resolved] First click on the site (2 posts)

  1. pooledge
    Member
    Posted 1 year ago #

    Hi there!

    I have a menu in the slidebar. This one makes no problem, everything works just fine - by clicking a menu item, a content element reloads.
    Also, there are hyperlinks inside a content element, which also work (nice!), but only after a content element was already reloaded per AJAXpl once!
    Means:
    page fresh loaded -> click on hyperlink inside content element -> complete reload;
    page fresh loaded -> click on any menu item -> content element reloaded -> click on hyperlink inside content element -> content element reloaded

    Here is my reload code:

    // arrow-left on :hover
    jQuery('div#post-container a.event-morelink').mouseenter(function() {
           jQuery(this).children('div.event.entry').css('background','url('+templateUrl+'/images/arrow-left.png) no-repeat right center');
    });
    jQuery('div.event.entry').mouseleave(function() {
    	jQuery(this).css('background','none');
    });
    
    // jQuery ColorBox
    jQuery(document).ready(function($){
    		jQuery(".gallery").each(function(index, obj){
    		var galleryid = Math.floor(Math.random()*10000);
    		jQuery(obj).find("a").colorbox({rel:galleryid, maxWidth:"95%", maxHeight:"95%"});
    });
    jQuery("a.lightbox").colorbox({maxWidth:"95%", maxHeight:"95%"});
    });
    
    // Gallery
    jQuery('div#gallery-1 div.gallerySeparator').last().css('height','0px');
    jQuery('div#gallery-1').parent().css('padding-bottom','0');
    
    // Comment validation
    function validateForm()
    {
    var x=document.forms["commentForm"]["author"].value;
    if (x==null || x=="")
      {
      alert(unescape("Bitte %FCberpr%FCfen Sie den angegebenen Namen."));
      document.forms["commentForm"]["author"].focus();
      return false;
      }
    
    var z=document.forms["commentForm"]["email"].value;
    var atpos=z.indexOf("@");
    var dotpos=z.lastIndexOf(".");
    if (atpos<1 || dotpos<atpos+2 || dotpos+2>=z.length)
      {
      alert(unescape("Bitte %FCberpr%FCfen Sie die angegebene E-Mail-Adresse."));
      document.forms["commentForm"]["email"].focus();
      return false;
      }
    
    var y=document.forms["commentForm"]["comment"].value;
    var url=document.location.href;
    var currPage=url.slice(url.lastIndexOf('/')-7,url.lastIndexOf('/')+0);
    
    if (y==null || y=="" && currPage=="kontakt")
      {
    	  	alert(unescape("Bitte geben Sie den Text Ihrer Nachricht an."));
      	  	document.forms["commentForm"]["comment"].focus();
      		return false;
      }
    
    if (y==null || y=="" && currPage!="kontakt")
      {
    		alert(unescape("Bitte geben Sie den Text Ihres Kommentars an."));
      	  	document.forms["commentForm"]["comment"].focus();
      		return false;
      }
    
    var m=document.forms["mc_signup_form"]["mc_mv_EMAIL"].value;
    var atpos=m.indexOf("@");
    var dotpos=m.lastIndexOf(".");
    if (atpos<1 || dotpos<atpos+2 || dotpos+2>=m.length)
      {
      alert(unescape("Bitte %FCberpr%FCfen Sie die angegebene E-Mail-Adresse."));
      document.forms["mc_signup_form"]["mc_mv_EMAIL"].focus();
      return false;
      }
    }

    And the click code:

    // Prevent from clicking highlighted items /NON-FUNCTIONAL
    if ( jQuery(thiss).parent('li').hasClass( 'current-menu-item' ) || jQuery(thiss).hasClass( 'selected-menu-item' ) ) {
    	//alert ('bla');
    	event.preventDefault();
    };
    
    // Highlight the current menu item
    jQuery('ul.menu li').each(function() {
    	jQuery(this).removeClass('current-menu-item');
    });
    jQuery('ul.sub-menu').prev('a').each(function() {
    	jQuery(this).removeClass('selected-menu-item');
    });
    jQuery(thiss).parent('li').addClass('current-menu-item');
    
    // Highlight the parent menu item
    if (jQuery(thiss).parents('ul').hasClass('sub-menu') ) {
    	jQuery(thiss).parents('ul.sub-menu').prev('a').addClass('selected-menu-item');
    };
    
    // Highlight Events menu item
    if (jQuery(thiss).is('a.event-morelink') ) {
    	jQuery('li#menu-item-623 a').first().addClass('selected-menu-item');
    };

    Data AJAX Code is empty, jQuery Check checked.

    Any help is greatly appreciated
    pooledge

    http://wordpress.org/extend/plugins/advanced-ajax-page-loader/

  2. jim22150
    Member
    Posted 1 year ago #

    Both are loaded at the same time. Try collaborating your 'click' and 'reload' code and placing it all in the 'click' code box by it self so you aren't overwriting anything.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic