Hi Mike, essentially you are currently not passing a function as an
onchange callback, you're passing a statement.  That is not guaranteed
to do anything in particular other than possibly execute that
statement at the time the interpreter reaches that line in parsing
your script.

use this instead of your current onchange --

onchange: function (element) { alert('foo'); }

See, callbacks are expected to be functions, whether they are
anonymous and defined inline like this example, or previously
defined.  If you want to keep your code extra clean, you could have
previously defined it as, for example, this:

my_excellent callback = function (element) { alert( 'What you lookin
at?' ); };

then... $('targetDiv').update(new Element('input', {type:'text',
id:'blah', onchange: my_excellent_callback} ));

* Notice the lack of () after the reference to the callback function.
That is because you're not *calling* it there, you're supplying it as
an argument to a function/method.

Make sense?

On May 8, 1:06 pm, Mike <[EMAIL PROTECTED]> wrote:
> Hey guys,
>
> My team is have an issue using the Prototype DOM builder. For some
> reason, the onchange event isn't being registered for an input box.
>
> $('targetDiv').update(new Element('input',{type:'text', id:'blah',
> onchange:'alert();'}));
>
> When we insert via the .innerHTML parameter, it works just fine. Any
> thoughts? Thanks guys
>
> -Mike
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to