Yes!
jQuery support this aswell. It adds every onload/domready event in a
queue.

$(window).load(function(){
// do stuff onload
})
$(window).load(function(){
// do other stuff onload
})


But you should really look into some pattern instead. A relly simple
and good pattern is the "Module Pattern"
http://yuiblog.com/blog/2007/06/12/module-pattern/

You could then create you own namespaced object with init-methods and
have options for when and where your methods should be executed

Something like this

var MyObject = function(){

   return {
      init: function() {
       if ($('body').is('#home'))
           this.applySliderEvents()
      },
      onloadInit: function(){
        this.applySliderEvents()
      },
      applySliderEvents: function(){

      },
      applyOtherStufEvents: function(){

      }

   }
}()


$(document).ready(function(){
     MyObject.init()
})

$(window).load(function(){
  MyObject.onloadInit()
})



Just a relly basic example (and not the best optimized), but it might
give you a better idea what can be done with simple init-methods and
body-id's :)

Reply via email to