Problem with links and hitting enter in a form.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with links and hitting enter in a form.

Kalle Säilä
Hi guys,

my problem is related to DOMActivate event. Let's say that you have a form with multiple input fields and you want to trigger the submit button at the bottom of the form when the user hits the enter key in any input field. I know that if I put the input fields for example in group element I can dispatch the DOMActivate event in a single action inside the group but the problem is that if I have also links in the form the event also gets dispatched when the user clicks the link. I also know that I can solve this problem by putting the dispatch action inside all the input tags but this forces me to use the same code fragment in many places instead of just one. So my question is that is it possible to fire the dispatch action only if the DOMActivate event comes from an input field?

I attached a sample which runs on xforms sandbox.

-Kalle


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws

domActivateTest.xhtml (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Problem with links and hitting enter in a form.

Alessandro Vernet
Administrator
Kalle,

On Fri, Aug 1, 2008 at 2:51 AM, Kalle Säilä <[hidden email]> wrote:

> my problem is related to DOMActivate event. Let's say that you have a form
> with multiple input fields and you want to trigger the submit button at the
> bottom of the form when the user hits the enter key in any input field. I
> know that if I put the input fields for example in group element I can
> dispatch the DOMActivate event in a single action inside the group but the
> problem is that if I have also links in the form the event also gets
> dispatched when the user clicks the link. I also know that I can solve this
> problem by putting the dispatch action inside all the input tags but this
> forces me to use the same code fragment in many places instead of just one.
> So my question is that is it possible to fire the dispatch action only if
> the DOMActivate event comes from an input field?
Interesting question! In your event handler, in the <xforms:group> you
have around "everything", you can use event('xxforms:binding') to get
the node bound to the target of the event. If you don't have a
ref="..." or bind="..." on your triggers, then
event('xxforms:binding') will return an empty nodeset when you click
on triggers. E.g.:

<xforms:action ev:event="DOMActivate"
if="exists(event('xxforms:binding'))"> ... </xforms:action>

Note that triggers used to (incorrectly, according to the spec) be
bound to the context node even when you didn't have a ref/bind. So you
will need a fairly recent nightly build for this to work.

Alex
--
Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise
Orbeon's Blog: http://www.orbeon.com/blog/
Personal Blog: http://avernet.blogspot.com/
Twitter - http://twitter.com/avernet


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Problem with links and hitting enter in a form.

Kalle Säilä
Thanks Alex. I'll give it a try.

2008/8/8 Alessandro Vernet <[hidden email]>
Kalle,

On Fri, Aug 1, 2008 at 2:51 AM, Kalle Säilä <[hidden email]> wrote:
> my problem is related to DOMActivate event. Let's say that you have a form
> with multiple input fields and you want to trigger the submit button at the
> bottom of the form when the user hits the enter key in any input field. I
> know that if I put the input fields for example in group element I can
> dispatch the DOMActivate event in a single action inside the group but the
> problem is that if I have also links in the form the event also gets
> dispatched when the user clicks the link. I also know that I can solve this
> problem by putting the dispatch action inside all the input tags but this
> forces me to use the same code fragment in many places instead of just one.
> So my question is that is it possible to fire the dispatch action only if
> the DOMActivate event comes from an input field?

Interesting question! In your event handler, in the <xforms:group> you
have around "everything", you can use event('xxforms:binding') to get
the node bound to the target of the event. If you don't have a
ref="..." or bind="..." on your triggers, then
event('xxforms:binding') will return an empty nodeset when you click
on triggers. E.g.:

<xforms:action ev:event="DOMActivate"
if="exists(event('xxforms:binding'))"> ... </xforms:action>

Note that triggers used to (incorrectly, according to the spec) be
bound to the context node even when you didn't have a ref/bind. So you
will need a fairly recent nightly build for this to work.

Alex
--
Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise
Orbeon's Blog: http://www.orbeon.com/blog/
Personal Blog: http://avernet.blogspot.com/
Twitter - http://twitter.com/avernet


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws