Grow your CSS skills. Land your dream job.

Triggering jQuery after page has loaded

  • # November 23, 2012 at 10:26 am

    Hey there,

    I’ve been trying to figure this out for a while but with no luck.

    I’ve got an [html file](http://orchidaberdeen.com/ “”) that loads an [external html](http://orchidaberdeen.com/6_toggle/1.html “”) file and within that external html file is some jQuery that i need to work.

    The problem appears to be that my original file loads the jQuery but when the external page gets loaded it doesn’t trigger the jQuery from the original file, thus not working.

    I’ve tried the [get.Script](http://api.jquery.com/jQuery.getScript/ “”) but that doesn’t seem to work.

    Hoping someone would have some pointers?

    # November 23, 2012 at 11:19 am

    @CameronDuthie : I think an example would be best in this situation for people to see what you are working with.

    Is the JS that you are trying to have run wrapped in an anonymous function?
    why cant you just use the JS from the external in your main page, or both?
    Why not make that JS external and call it in from both?

    This is why an example would help you possibly get some narrower answers.

    # November 23, 2012 at 11:21 am

    @JohnMotylJr He did give links!

    # November 23, 2012 at 11:23 am

    @CameronDuthie : I take it you are referring to t_close_menu( )?

    # November 23, 2012 at 11:45 am

    @JohnMotylJr im actually meaning the gallery section on the main site, when you click on the circles the page expands open to reveal thumb nails. The thumb nail page is an external html file that is stored in a folder called **6_toggle** and is getting loaded into the index.html file by this,

    t_slide.load(“6_toggle/”+page+”.html”);

    But this function doesn’t seem to like to load the jQuery from its external page.

    So i’m just trying to find a workaround that will re-trigger the jQuery so the thumbnails display a lightbox effect that i’ve got set up.

    # November 23, 2012 at 1:53 pm

    @CameronDuthie : If you’r loading another html page inside your first one then try to target it with js from the second, im not really sure if the secondary js will pick up on the DOM. Have you tried just putting that code from your second html file into an anonymous function on your main page?

    Hmm, actually, are you referring to the light box script?

    Try loading all that into your main html page.

    # November 23, 2012 at 5:47 pm

    @JohnMotylJr Thank you for you help man, but i’ve actually tried all those suggestions. Yeah you got it, it’s the lightbox script i’m trying to implement.

    No matter where i put the reference the jquery just doesn’t seem to want to load/trigger from the second html file.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".