You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Eelco Hillenius <ee...@gmail.com> on 2007/09/11 06:44:55 UTC

on the default button in Form

Hi,

Can anyone please tell me what this:

		buffer.append("\" onclick=\" var b=Wicket.$('");
		buffer.append(submittingComponent.getMarkupId());
		buffer.append("'); if (typeof(b.onclick) != 'undefined') {  var r =
b.onclick.bind(b)(); if (r != false) b.click(); } else { b.click(); };
 return false;\" ");


is supposed to do? The idea of adding that hidden submit button there
is that it *typically* (depending on the browser and whether multiple
forms are nested) would be picked up as the first button by the
browser and thus act like a 'default' button that is executed when
enter is pushed. I don't really see how it can be clicked on. And is
"b.onclick.bind(b)()" a typo?

Eelco

Re: on the default button in Form

Posted by Sebastiaan van Erk <se...@sebster.com>.
Ah, that would explain why clicking on the image made it change. :-)

Actually pretty logical (hate to say it ;-)). However, firefox changes 
it immediately... so nice that everybody has their own interpretation. :-(

Regards,
Sebastiaan

Johan Compagner wrote:
> IE also triggers onchange, just loose the focus as long as you have the
> focus on it
> it doesnt fire.
> 
> johan
> 
> 
> On 9/11/07, Sebastiaan van Erk <se...@sebster.com> wrote:
>> Hi Eelco,
>>
>> Keyboard actions on components can actually trigger an onClick on the
>> component.
>>
>> I had javascript rendering problems in IE with a checkbox with an
>> onChange that changed an img src. The src of the image would be changed,
>> but IE just refused to update the screen. When I changed the onChange to
>> onClick, suddenly IE did work. However, the point is, that you would
>> expect onChange to fire when you change the value of the checkbox with
>> the keyboard, whereas you would expect onClick not to. However in ALL
>> browsers I tested, changing the value of the checkbox with the keyboard
>> ALSO triggered onClick.
>>
>> Regards,
>> Sebastiaan
>>
>> Eelco Hillenius wrote:
>>> Hi,
>>>
>>> Can anyone please tell me what this:
>>>
>>>               buffer.append("\" onclick=\" var b=Wicket.$('");
>>>               buffer.append(submittingComponent.getMarkupId());
>>>               buffer.append("'); if (typeof(b.onclick) != 'undefined')
>> {  var r =
>>> b.onclick.bind(b)(); if (r != false) b.click(); } else { b.click(); };
>>>  return false;\" ");
>>>
>>>
>>> is supposed to do? The idea of adding that hidden submit button there
>>> is that it *typically* (depending on the browser and whether multiple
>>> forms are nested) would be picked up as the first button by the
>>> browser and thus act like a 'default' button that is executed when
>>> enter is pushed. I don't really see how it can be clicked on. And is
>>> "b.onclick.bind(b)()" a typo?
>>>
>>> Eelco
>>
> 

Re: on the default button in Form

Posted by Johan Compagner <jc...@gmail.com>.
IE also triggers onchange, just loose the focus as long as you have the
focus on it
it doesnt fire.

johan


On 9/11/07, Sebastiaan van Erk <se...@sebster.com> wrote:
>
> Hi Eelco,
>
> Keyboard actions on components can actually trigger an onClick on the
> component.
>
> I had javascript rendering problems in IE with a checkbox with an
> onChange that changed an img src. The src of the image would be changed,
> but IE just refused to update the screen. When I changed the onChange to
> onClick, suddenly IE did work. However, the point is, that you would
> expect onChange to fire when you change the value of the checkbox with
> the keyboard, whereas you would expect onClick not to. However in ALL
> browsers I tested, changing the value of the checkbox with the keyboard
> ALSO triggered onClick.
>
> Regards,
> Sebastiaan
>
> Eelco Hillenius wrote:
> > Hi,
> >
> > Can anyone please tell me what this:
> >
> >               buffer.append("\" onclick=\" var b=Wicket.$('");
> >               buffer.append(submittingComponent.getMarkupId());
> >               buffer.append("'); if (typeof(b.onclick) != 'undefined')
> {  var r =
> > b.onclick.bind(b)(); if (r != false) b.click(); } else { b.click(); };
> >  return false;\" ");
> >
> >
> > is supposed to do? The idea of adding that hidden submit button there
> > is that it *typically* (depending on the browser and whether multiple
> > forms are nested) would be picked up as the first button by the
> > browser and thus act like a 'default' button that is executed when
> > enter is pushed. I don't really see how it can be clicked on. And is
> > "b.onclick.bind(b)()" a typo?
> >
> > Eelco
>
>

Re: on the default button in Form

Posted by Eelco Hillenius <ee...@gmail.com>.
On 9/11/07, Gerolf Seitz <ge...@gmail.com> wrote:
> from looking at the source in wicket-ajax.js, bind returns a function.
> the rest is pretty obvious ;)

Duh!

Thanks, I should have dug deeper. I guess it's late here.

Eelco

Re: on the default button in Form

Posted by Gerolf Seitz <ge...@gmail.com>.
from looking at the source in wicket-ajax.js, bind returns a function.
the rest is pretty obvious ;)

gerolf


On 9/11/07, Eelco Hillenius <ee...@gmail.com> wrote:
>
> On 9/11/07, Matej Knopp <ma...@gmail.com> wrote:
> > It's not a typo. It's javascript :-)
>
> I was afraid someone would say that :)
>
> b.onclick.bind(b)() <-- the second pair of parenthesis, what does that
> mean?
>
> Eelco
>

Re: on the default button in Form

Posted by Matej Knopp <ma...@gmail.com>.
On 9/11/07, Eelco Hillenius <ee...@gmail.com> wrote:
> On 9/11/07, Matej Knopp <ma...@gmail.com> wrote:
> > It's not a typo. It's javascript :-)
>
> I was afraid someone would say that :)
>
> b.onclick.bind(b)() <-- the second pair of parenthesis, what does that mean?

Okay, it goes like this:
b.onclick is the handler method
b.onclick.bind(b) actually wraps the previous in method, that passes
"b" as this. so b.onclick.bind(b) generates a method.
and the extra () invoke the method.

-Matej

>
> Eelco
>

Re: on the default button in Form

Posted by Eelco Hillenius <ee...@gmail.com>.
On 9/11/07, Matej Knopp <ma...@gmail.com> wrote:
> It's not a typo. It's javascript :-)

I was afraid someone would say that :)

b.onclick.bind(b)() <-- the second pair of parenthesis, what does that mean?

Eelco

Re: on the default button in Form

Posted by Matej Knopp <ma...@gmail.com>.
It's not a typo. It's javascript :-)

the bind(b) make sure that if you use this inside onclick handler, it
points to the submitting instance, just like it would if you clicked
the button.

The entire code is to make sure that default button works for ajax
buttons too (as the implementation before just submitted the entire
form regularly).

-Matej

On 9/11/07, Eelco Hillenius <ee...@gmail.com> wrote:
> On 9/10/07, Sebastiaan van Erk <se...@sebster.com> wrote:
> > Hi Eelco,
> >
> > Keyboard actions on components can actually trigger an onClick on the
> > component.
> >
> > I had javascript rendering problems in IE with a checkbox with an
> > onChange that changed an img src. The src of the image would be changed,
> > but IE just refused to update the screen. When I changed the onChange to
> > onClick, suddenly IE did work. However, the point is, that you would
> > expect onChange to fire when you change the value of the checkbox with
> > the keyboard, whereas you would expect onClick not to. However in ALL
> > browsers I tested, changing the value of the checkbox with the keyboard
> > ALSO triggered onClick.
>
> Ah, thanks for explaining Sebastiaan.
>
> what about this: b.onclick.bind(b)() ?
>
> Eelco
>

Re: on the default button in Form

Posted by Eelco Hillenius <ee...@gmail.com>.
On 9/10/07, Sebastiaan van Erk <se...@sebster.com> wrote:
> Hi Eelco,
>
> Keyboard actions on components can actually trigger an onClick on the
> component.
>
> I had javascript rendering problems in IE with a checkbox with an
> onChange that changed an img src. The src of the image would be changed,
> but IE just refused to update the screen. When I changed the onChange to
> onClick, suddenly IE did work. However, the point is, that you would
> expect onChange to fire when you change the value of the checkbox with
> the keyboard, whereas you would expect onClick not to. However in ALL
> browsers I tested, changing the value of the checkbox with the keyboard
> ALSO triggered onClick.

Ah, thanks for explaining Sebastiaan.

what about this: b.onclick.bind(b)() ?

Eelco

Re: on the default button in Form

Posted by Sebastiaan van Erk <se...@sebster.com>.
Hi Eelco,

Keyboard actions on components can actually trigger an onClick on the 
component.

I had javascript rendering problems in IE with a checkbox with an 
onChange that changed an img src. The src of the image would be changed, 
but IE just refused to update the screen. When I changed the onChange to 
onClick, suddenly IE did work. However, the point is, that you would 
expect onChange to fire when you change the value of the checkbox with 
the keyboard, whereas you would expect onClick not to. However in ALL 
browsers I tested, changing the value of the checkbox with the keyboard 
ALSO triggered onClick.

Regards,
Sebastiaan

Eelco Hillenius wrote:
> Hi,
> 
> Can anyone please tell me what this:
> 
> 		buffer.append("\" onclick=\" var b=Wicket.$('");
> 		buffer.append(submittingComponent.getMarkupId());
> 		buffer.append("'); if (typeof(b.onclick) != 'undefined') {  var r =
> b.onclick.bind(b)(); if (r != false) b.click(); } else { b.click(); };
>  return false;\" ");
> 
> 
> is supposed to do? The idea of adding that hidden submit button there
> is that it *typically* (depending on the browser and whether multiple
> forms are nested) would be picked up as the first button by the
> browser and thus act like a 'default' button that is executed when
> enter is pushed. I don't really see how it can be clicked on. And is
> "b.onclick.bind(b)()" a typo?
> 
> Eelco