on 2014-06-22 02:35
on 2014-06-22 02:45
Okay, I've found why!!! But this arise another question. I've tested this: erased one of the files, in the other I've added a window.onload below the first window.onload and a strange thing happened: the last window.onload gets executed, but not the first. So this takes me to the conclusion: I can't "monkeypatch" window.onload, can be called just once, not only once in one *.js, even in the whole JS filesystem. Why works this way?
on 2014-06-22 05:20
Been doing some little more stuff. If I put the code of both *.js on the corresponding views(inside <script></script>) works like a charm. So why?
on 2014-06-22 18:27
On Sat, Jun 21, 2014 at 5:45 PM, Damián M. González <email@example.com> wrote: > Okay, I've found why!!! But this arise another question. > I've tested this: erased one of the files, in the other I've added a > window.onload below the first window.onload and a strange thing > happened: the last window.onload gets executed. > So this takes me to the conclusion: I can't "monkeypatch" > window.onload, can be called just once, not only once in one JS, even in > the whole JS filesystem. Why works this way? If you open a JS console and enter: > x = 'foo' > x = 'bar' > x what value does `x` have? Hint: it's not 'foobar' :-) Now try the same thing with `window.onload`. If you want to avoid using libraries like jQuery for now, look at native JS methods like e.g. window.addEventListener() HTH, -- Hassan Schroeder ------------------------ firstname.lastname@example.org http://about.me/hassanschroeder twitter: @hassan
on 2014-06-22 22:15
Yes, I've realized that onload is an attribute of window, so if I do window.onload = something twice I'm overwriting the value of the attribute. Thanks.