I have this fiddle http://jsbin.com/EvIYomiF/4/ and just to noticed in case that its matter the javascript is in two files.
Well.. as you can see in the demo, the dom scope is being overwritten somehow and I want to understand why. I mean, the self=this hack is for sure a bad practice, but I don't understand why is being overwritten
I don't find words to describe the problem, I'm sorry for that, but the fiddle is the only way that I found to explain my problem easyly.
All the conjecture about this
is irrelevant and everyone has been leading you down the wrong trail.
The problem is that self
has not been insulated by using var
so it is therefore global. The second self
overwrites the first.
Simply making it var self=this
makes it all work. What you have done is common practice to avoid the change of context of this
within the jQuery event handler