0

I'm aware this might be a repeated question, but it's not

I already looked at this one

CollapsiblePanelExtender: Can not get object in onLoad of page (AJAX Toolkit)

I had tried the following load functions in order to achieve my goal

window.onload = setExtenderEvents;
document.addEventListener('DOMContentLoaded', setExtenderEvents, false);
window.addEventListener('load', setExtenderEvents, false)
document.body.onload = setExtenderEvents;

enter image description here

So, I'm getting a null. Of course, after I keep on executing this error and everything loads fine, I'm able to get the extender object

enter image description here

Any idea how can I achieve this. In chrome, and firefox, setting the event listener to load works perfectly. IE10 it's the one giving me a awful time and no, I can't use any framework. I am allowed to use only pure vanilla js

Community
  • 1
  • 1
CJLopez
  • 5,495
  • 2
  • 18
  • 30

1 Answers1

1

It seems you are trying to add an event too early.

Try using Sys.Application.add_load event:

Sys.Application.add_load(function() {
    var cpeDemo = $find('searchCollapse');
    cpeDemo.add_collapsing( ... );
}