Maybe instead of putting "onclick" inside the Element constructor, use the
observe method instead.

confirmation_button = new Element('input', {type: 'button', value: 'Ok'});
confirmation_button.observe("click", function() {alert("button click");});



On Thu, Feb 4, 2010 at 11:23 AM, Ian <[email protected]> wrote:

> Hello,
>
> I ran into a problem when creating some new elements. I'm sure the
> problem is mine, but I can't figure out the mistake I made. Hopefully
> someone here can point out my error.
>
> Using Prototype 1.6.0.2, I created and inserted two new elements into
> a page.
>
> popup_wrapper = new Element('div', {
>                       id: 'logout_warning_popup',
>                       style: 'position:relative;'
>
> confirmation_button = new Element('input', {
>                                    type: 'button',
>                                    value: 'Ok',
>                                    onclick: "window.alert('button
> clicked');"
>
> popup_wrapper.insert(confirmation_button);
> $('content').insert(popup_wrapper);
>
> Very simple. In both IE7 and Firefox (3.5.7), the box and button
> appeared correctly on the page. When I clicked on the "Ok" input in
> Firefox, I received the 'button clicked' alert box. But when I clicked
> the box in IE7, I got no alert box at all. And no indication that a js
> error had occurred.
>
> My first thought was that there might be a HTML syntax error that was
> causing the IE problem. So I copied the HTML created by the above code
> and made it a static part of the page. Now the button worked properly
> in both IE and FF.
>
> So there's something wrong in my creation of the elements that is
> preventing the onclick event from firing, and I'm not sure what that
> is. Any advice?
>
> Thanks,
>
> Ian
>
> --
> You received this message because you are subscribed to the Google Groups
> "Prototype & script.aculo.us" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected]<prototype-scriptaculous%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/prototype-scriptaculous?hl=en.
>
>


-- 
Matt Milburn
President, Web Developer & Graphic Designer
Phone: (405) 213-4353
AIM: wavemotion777

Wave Motion Studios
www.wavemotionstudios.com

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" 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/prototype-scriptaculous?hl=en.

Reply via email to