jQuery .ready event on dynamic content

Total Post:24

Points:168

JQuery 
 1626  View(s)
Ratings:
Rate this:

I have a dynamic list loaded into an 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.

  1. Re: jQuery .ready event on dynamic content

    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.
        });
    });

      Modified On Apr-03-2018 04:38:36 AM

Answer

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.