Using DomReady extenstion for prototype with control modal??

Hi, I'm a big fan of this control suite, the only thing is that when using ajax modals before the page loads it directs to the actual URL, or if the modal is not ajax, it will not load up until the page finishes loading, I believe this is...

attachEvents: function(){
    Event.observe(window,'load',Control.Modal.load);
    Event.observe(window,'unload',Event.unloadCache,false);

Here is a Dom Ready Extension for prototype, how can I implement this with control modal??

Object.extend(Event, {
  _domReady : function() {
    if (arguments.callee.done) return;
    arguments.callee.done = true;
    if (this._timer)  clearInterval(this._timer);
    this._readyCallbacks.each(function(f) { f() });
    this._readyCallbacks = null;
},
  onDOMReady : function(f) {
    if (!this._readyCallbacks) {
      var domReady = this._domReady.bind(this);
      if (document.addEventListener)
        document.addEventListener("DOMContentLoaded", domReady, false);
        /*@cc_on @*/
        /*@if (@_win32)
            document.write("");
            document.getElementById("__ie_onload").onreadystatechange = function() {
                if (this.readyState == "complete") domReady(); 
            };
        /*@end @*/
        if (/WebKit/i.test(navigator.userAgent)) { 
          this._timer = setInterval(function() {
            if (/loaded|complete/.test(document.readyState)) domReady(); 
          }, 10);
        }
        Event.observe(window, 'load', domReady);
        Event._readyCallbacks =  [];
    }
    Event._readyCallbacks.push(f);
  }
});

Any help is GREATLY appreciated!

Posted July 6th, 2007 at 12:54pm by ericzhivalyuk

Im testing it right now for you :) not sure yet -.-

Posted July 6th, 2007 at 3:01pm by Roland

Event.onDOMReady(function(){
    alert(1);
});

Posted July 6th, 2007 at 3:10pm by Roland

Alright, so it looks like it works

 Event.onReady(function() {
    new Control.Modal($('logout'), {
        containerClassName: 'dialog',
        overlayClassName: 'dialog',
        fade: true,
        opacity: 0.65,
        width: 480,
        height: 150
    });
});

Posted July 8th, 2007 at 2:51pm by ericzhivalyuk

I made the following change;


attachEvents: function(){  
    //Event.observe(window,'load',Control.Modal.load);  
    Event.onDOMReady(Control.Modal.load);
    Event.observe(window,'unload',Event.unloadCache,false);  
}

Posted July 9th, 2007 at 4:33am by Roland

Login or Register to Post