2008/5/22 Gareth Evans
<agrath-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> Hi Guys
>
> I''m having some problems getting a custom event to fire using the
following
> code
>
>
> Event.observe(window,
>
> ''load'', function(e){
> initCustomField($(''customFieldForm''));
> document.observe(''CustomField:TypeChanged'',function(e){
> alert(''event'');
> var optionsField = $(''OptionsField'');
> if(e.target.value == 4) optionsField.show();
> else optionsField.hide();
> });
> });
>
> function
>
> initCustomField(customFieldForm)
> {
> //var panel = customFieldForm.down(''.customFieldPanel'');
> //initCustomFieldOptionPanel(panel);
>
$$(''input[type=radio][name^=CustomFieldType]'').each(function(radio){
> radio.observe(''click'', function(e){
> this.fire(''CustomField:TypeChanged'');
> });
> }).find(function(radio){ return radio.checked;
> }).fire(''CustomField:TypeChanged'');
> }
>
> When I click a radio button, the event fires and all is well, but
i''m trying
> to also fire the event on the (server selected) radio button on page load.
>
> Can anyone see what I''ve done wrong?
>
>
>
> Gareth
>
> >
>
Try ..
document.observe(''dom:loaded'', ....);
rather than
Event.observe(''load'', ...);
--
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---