On Sat, Jun 21, 2014 at 5:45 PM, Damián M. González
<li...@ruby-forum.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 ------------------------ hassan.schroe...@gmail.com
http://about.me/hassanschroeder
twitter: @hassan

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yDWSzoAZoZS-5bMMZ0Vjk6Zg4LsmKiHuyOp6fTPS%3DMUbQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to