Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery: How do I wrap() a dynamically loaded element?

Tags:

jquery

I am skinning a 3rd party app that has no HTML natively. It all comes back from an onLoad event and a bunch of ajax calls.

I added jQuery to the page. I need to wrap() an element that is dynamically loaded. I can include a plugin if needed.

How do I do this? Thanks.

UPDATE: This works, but is there a better way?

$(document).ready(function() {

(function() {
  var length = $(".applicationShell").length;

  var h = setInterval(function () {
    if ($(".applicationShell").length > length) {
      length = $(".applicationShell").length;
      clearInterval(h);


      $(".applicationShell").addClass("test")

    }
  }, 100);
})();


});
like image 511
Glen Lipka Avatar asked Nov 15 '22 08:11

Glen Lipka


1 Answers

Well, it seems I can't find a better solution. :( Here is the one I used.

$(document).ready(function() {

(function() {
  var length = $(".applicationShell").length;

  var h = setInterval(function () {
    if ($(".applicationShell").length > length) {
      length = $(".applicationShell").length;
      clearInterval(h);


      $(".applicationShell").addClass("test")

    }
  }, 100);
})();


});
like image 124
Glen Lipka Avatar answered Dec 24 '22 10:12

Glen Lipka