0

I have page specific html loading into an iFrame which contains objects that I'm trying to reference with jquery. When the page loads initially the elements are found as expected, but if I go to a new page and return or refresh the page the elements are no longer found consistently (fails more often then not) until I clear the cache and reload the page.

I've tried different combinations of querySelectorAll and getElementsByClassName but they only work consistently that first time in. It would seem like a race condition but why would it work the first time?

Does this problem sound familiar to anyone?

Quinnland23
  • 486
  • 1
  • 3
  • 10
  • Have you already try to debug iFrame elements in page with Firefox Firebug extension or Firefox developer tools? Where are you reference to iFrame object and how you create iFrame? By jQuery or in "standard way", by html? Try to give a look to http://stackoverflow.com/questions/205087/jquery-ready-in-a-dynamically-inserted-iframe – deste Mar 06 '13 at 22:02

1 Answers1

0

It did turn out to be a race condition where the dynamic elements were not yet available for reference. In my case the iFrame element was created using ExtJS so it needed this additional listener so I could take action after the load (putting this delay in afterrender came from another post that I'll need to find and give credit to);

afterrender: function (cmp) {
   var element = cmp.getEl();
   element.on('load', function () {
       renderer.onIFrameReady();
   });
}
Quinnland23
  • 486
  • 1
  • 3
  • 10