Mark Kang
Mark Kang

Reputation: 131

How to run jQuery function AFTER the content is loaded

So, I know that using AJAX, it is possible to run jQuery funtions after the content is loaded.

If you can go to this webpage and click on the menu that says '공지사항' http://lifeto.cafe24.com/xe/

Try clicking any of the images on the board, and you will notice a div slides in. But I was wondering if it's possible to have the div slide in AFTER the jQuery attr funtion is complete.

Or if it's impossible, is there a way around it?

I've already tried it using AJAX, but there seems to be a glitch, so I prefer using iframes and jQuery animations.

Here is the JS code.

jQuery(document).ready(function(){
    jQuery(document).on('click', '.item', function() {
        jQuery('.loader_container_2', parent.document.body).show();
        var url = jQuery(this).data('url');

        jQuery('#iframe_board', parent.document.body).attr('src', url, 200);

        jQuery('#window_frame', parent.document.body).addClass('open animated slideOutLeft');
        setTimeout(function() {
            jQuery('.window_board', parent.document.body).removeClass('animated slideOutLeft');
            jQuery('.window_board', parent.document.body).addClass('open animated slideInLeft');
        }, 400);

        jQuery('.loader_container_2', parent.document.body).hide();

    });
});

Upvotes: 0

Views: 54

Answers (1)

Brady Cartmell
Brady Cartmell

Reputation: 607

jQuery has a load event handler for this purpose:

jQuery('#iframe_board', parent.document.body).attr('src', url).load(functino() {
//....do your thing....
});

Upvotes: 1

Related Questions