Cant get onClick definitions to work for buttons created thru forms.js

2 views
Skip to first unread message

unomi

unread,
Sep 30, 2008, 4:50:15 AM9/30/08
to inputex
trying with :
buttons: [{type: 'submit', value: 'Login'},{type: 'button', value:
'New User', onClick:'alert(this.value);' }],

and others, but no joy. any hints?

Thanks

Eric Abouaf

unread,
Sep 30, 2008, 5:53:02 AM9/30/08
to inp...@googlegroups.com
onClick should be a function

ex :

buttons: [{type: 'submit', value: 'Login'},{type: 'button', value:
'New User', onClick: function() { alert(this.value); } }],

This is not really json anymore... :(
Maybe I'll add an eval if onClick is a string...

unomi

unread,
Sep 30, 2008, 6:06:13 AM9/30/08
to inputex
ahh *redface*

well i ended up adding it myself, hacky:
if( YAHOO.lang.isString(button.onClick) ) {
buttonEl.onclick = button.onClick;
YAHOO.util.Event.addListener(buttonEl, "click", function(e)
{eval(button.onClick)});
}
this.buttons.push(buttonEl);



On Sep 30, 4:53 pm, "Eric Abouaf" <eric.abo...@gmail.com> wrote:
> onClick should be a function
>
> ex :
> buttons: [{type: 'submit', value: 'Login'},{type: 'button', value:
> 'New User', onClick: function() { alert(this.value); } }],
>
> This is not really json anymore... :(
> Maybe I'll add an eval if onClick is a string...
>
> 2008/9/30 unomi <guidebook.in...@gmail.com>
Reply all
Reply to author
Forward
0 new messages