WordPress.org

Forums

Advanced AJAX Page Loader
[resolved] getting it to work without adding jquery (20 posts)

  1. Corey Ellis
    Member
    Posted 3 years ago #

    I LOVE this plug-in. I have a ton of js running for a particular client. When the plug adds the jquery that is supplied w/ the plug it breaks the other scripts (because jquery is being called twice) but when I remove the line that adds jquery from the php file the plug doesn't work anymore. Can you help me get it to work with jquery already loaded from the wp_includes?

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

  2. Dean Williams
    Member
    Plugin Author

    Posted 3 years ago #

    Hey Corey, please contact me on my email address:

    deano@resplace.net

    I will be happy to help you get this working.

  3. Dean, if you're going to be supporting this via email and not on the forums, please do us the favor of posting that in your ReadMe (in the FAQ?) so it's easy for people to find.

  4. Dean Williams
    Member
    Plugin Author

    Posted 3 years ago #

    Of course I will, but first I need to figure out the actual issue and fix it for her.

    I will then either release an appropriate update or share a solution for any specific problem that's being caused for her.

    Thanks.

  5. Dean Williams
    Member
    Plugin Author

    Posted 3 years ago #

    And I'm being supportive via the forums. I just cant fix a problem with no URL or any way to track what the problem is. Hence why I have asked for more personal discussion so we can rectify the issue as quick as possible.

    Be rest assured that any development will be posted back here.

  6. Dean Williams
    Member
    Plugin Author

    Posted 3 years ago #

    Okay after looking into the problem a little there are a few obvious problems which I will explain below.

    But there is some unknown trouble too, javascript seems to stop working with some of the content on the page that isn't even changing, such as the menu. JavaScript is complaining that functions are missing which is possibly due to the removal of some javascript or something missing between my jquery include and the default of her site.

    Anyway always remember these two rules...

    FIRST:
    ------
    Any inline javascript in the HTML being loaded via AJAX will be lost and not executed or even available on the page. This is a security feature I believe.

    SECOND:
    -------
    If you have anything like a fancybox/lightbox for opening all images into a larger preview then these sort of things will not work with new HTML is loaded into the page. To combat this you have to recall the bindings when the ajax has finished loading the content.

    I will drop some more information into the FAQ as soon as I have time. Also working to help Corey get around these issues if I can.

  7. Dean Williams
    Member
    Plugin Author

    Posted 3 years ago #

    The second point I think I can rectify by re-calling document.ready, but the first issue still counts and without some major work is unavoidable.

  8. pawel_nopl
    Member
    Posted 3 years ago #

    Great work! I had a need for such a plugin for a long time ago
    I have the same problem as Corey... It would be nice to hear some solution for breaking of the other scripts :)

  9. Dean Williams
    Member
    Plugin Author

    Posted 3 years ago #

    We have worked it all out, the only problem now is a plugin for royalslider.

    It's instance needs to be destroyed and re-initialised once the ajax content has been loaded into the page... I'm just figuring out the code for that now and I will add a quickfix to the JS (so you can enable the fix easily).

    I have already added a way to not load the jquery if it is initialised already.

  10. Of course I will, but first I need to figure out the actual issue and fix it for her.

    The point isn't that. If people are emailing you with the info, it doens't help the next guy who may or may not have the same problem. Often all they see is this:

    OP: I have a problem!
    Dev: Email me!
    OP: Yay! You fixed it!

    ... See how that's annoying? :) We want to encourage you to have the dialogue with the user here. That's why these nifty support forums exist ;) If you need to take it to email, for privacy reasons or whatever, we understand, but we ask that you come back and explain what happened. Which you did. And that's awesome.

    Seeing an initial post of 'Email me!' sends up red-flags though.

  11. euphoriuhh
    Member
    Posted 3 years ago #

    I'm having issues reloading the javascript content after the page is loaded.

    I am using a custom theme that utilizes a nivoSlider on the homepage and lightboxes on many other pages.

    Can you please provide some more documentation or examples on how you reload the bindings / javascripts in the ajax-page-loader.js file?

    Thanks so much for a great plugin.

  12. Dean Williams
    Member
    Plugin Author

    Posted 3 years ago #

    Hey! Just saw your comment here and on my blog, it's a little late over here in the UK so I will reply in details sometime tomorrow! I promise!!

  13. Dean Williams
    Member
    Plugin Author

    Posted 3 years ago #

    Right okay the first thing you need to do is locate the code which binds the nivoSlider to the element on the page (the setup code).

    Once you have this you would usually drop it just after this code in the JS file:

    /////////////////////////////////////////
    // DROP YOUR RELOAD CODES BELOW HERE //
    /////////////////////////////////////////

    BTW I'm releasing an update in about 3 minutes, and then you will see the above marker in the JS file (doesn't exist right now).

  14. euphoriuhh
    Member
    Posted 3 years ago #

    Thank you! That helped. I've got all my custom JS reloaded and it seems to be working well. It seems like a shame to have to duplicate so much JS code but I'm not too worried about performance on this project. Thank you!

    Unfortunately, I am still fighting against one issue.. When navigating around the site, the custom menu is not updating the highlighted tab. I'll do some digging on my own but figured I'd mention it. Is this something you've come up against?

    Thanks again!

  15. euphoriuhh
    Member
    Posted 3 years ago #

    Also. Something else I'm experiencing. If I start on the homepage and navigate around, everything seems to work really well.

    However, if I start on a different page, when I try to load the homepage, it doesn't seem to load the content successfully.

    Just mentioning it. I'll continue debugging as well.

    Thanks!

  16. euphoriuhh
    Member
    Posted 3 years ago #

    Hey Dean and everyone. Sorry for the many successive posts! I wanted to come back and report that I came up with a solution for the menu tab highlighting issue. It might be a nice addition if you want to merge it back into the main branch of the plugin.

    in ajax-page-loader.js , pageLoaderInit()

    // highlight the current menu item
    $('ul.menu li').each(function() {
    	$(this).removeClass('current-menu-item');
    });
    $(this).parents('li').addClass('current-menu-item');
  17. Dean Williams
    Member
    Plugin Author

    Posted 3 years ago #

    congratulations on figuring it out, yes I know its a shame to have to re-call everything but there is no other way round unfortunately...
    You could try wrapping all the code into:
    $(document).ready(function() {

    });
    As my script already auto-calls this function back, this would mean your code is in one position. Not 100% sure it works though (have not tested it but should work).

    Firstly what is that code above actually fixing? Is it a wordpress feature or a feature of some other JavaScript?

    also for the nivoSlider, what code did you re-call? I can add this to the FAQ as "how to fix nivoSlider".

    Any other systems like this I would like some code snippets as many people could be using them.

    Thanks.

  18. Dean Williams
    Member
    Plugin Author

    Posted 3 years ago #

    BTW. Any new problems, anyone, please start a new topic with a good description. Setting this "resolved".

  19. euphoriuhh
    Member
    Posted 3 years ago #

    The snippet I posted enables the current tab highlighting in a custom navigation menu. It wasn't working beforehand, not sure if you were expecting it to. The URL was updating with each AJAX page load but the highlighted nav tab (which is set via the .current-menu-item class) wasn't updating.

    So my snippet basically removes the class from each nav li and then applies it to the li (and/or its parents) which just triggered the ajax load. Hopefully that makes sense.

    As for the nivoSlider... My particular reload code looked like

    /////////////////////////////////////////
    // DROP YOUR RELOAD CODES BELOW HERE //
    /////////////////////////////////////////
    $('#slider').nivoSlider({
    pauseTime:3000,
    effect:'boxRandom',
    animSpeed:700,
    directionNav:true,
    controlNav: false
    });

    ..... followed by much more custom JS from all over my site.

    Thanks again for everything, Dean!

  20. Dean Williams
    Member
    Plugin Author

    Posted 3 years ago #

    I have implemented this and I have included your nivoslider solution to the examples.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Advanced AJAX Page Loader
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic