I was just reading an article by Aaron about memory leaks, and
although he does say what is bad he does not say what is good.
So from the example this is bad:
function sayHi(observeId, message) {
  var el = $(observeId);
  Event.observe(el, "click", function() {
    alert(message);
  });
}

But what is good?
Is this:
function sayHi(observeId, message) {
  Event.observe($(observeId), "click", function() {
    alert(message);
  });
}

Also, which of these 2 is good and which is bad:
var someEl = new Element('div',{'id':'someEl'})
someEl.addEvent('click',function(){
  alert('bla')
})
someEl.injectInside($(somediv))

Or this:
var someEl = new Element('div',{'id':'someEl'})
someEl.injectInside($(somediv))

$('someEl').addEvent('click',function(){
  alert('bla')
})

Reply via email to