Home > DeveloperSection > Forums > jQuery .ready event on dynamic content
Kate Smith
Kate Smith

Total Post:24

Points:168
Posted on    October-14-2013 3:39 AM

 JQuery JQuery 
Ratings:


 1 Reply(s)
 807  View(s)
Rate this:

I have a dynamic list loaded into a HTML 5 web app built using jquery mobile + (jquery and javascript).

I want to display a simple "loading..." image by placing a <div> on the page while the list is populated dynamically. Once the list is complete I need a event to fire to remove the "loading..." image. Is it possible to attach the .ready or .load events to a element of the dynamic list so I get a event to fire when the list has loaded?

Thanks for any advice, searching for existing answers on the .ready subject only provides results about document.ready use of the event.



Hank Greenberg
Hank Greenberg

Total Post:12

Points:84
Posted on    October-14-2013 4:06 AM

Use the callback function.

$(function() {
    $('#content').html('<div>loading...</div>');
    $('#content').load('http://mynewcontent.com/', function(data) {
        // optional: do more stuff here.. not needed since the content will already be replaced.
    });
});

Don't want to miss updates? Please click the below button!

Follow MindStick