: My form:...">

Prevent TextField with action to submit its form

I have {{view Ember.TextField action="foo"}}

nested within a tag <form>

:

My form:
<form>
  {{view Ember.TextField action="foo"}}
</form>

      

I was hoping that clicking enter

on that textbox would trigger an action foo

without triggering an event submit

on its form (because it is Ember.TextField#bubbles

set to by default false

). But this is not the case: the page is reloading.

For semantic and integration purpose, I would like to keep the tag <form>

and not write the view Ember.Form

.

You can test it out in this JSFiddle .

How could I achieve this?

PS: I am using ember-latest:

  • version: v1.0.0-pre.4-31-g16442c5
  • last commit: 16442c5 (2013-01-23 23:48:09 -0800)
+3


source to share


2 answers


<form {{ action "" on="submit" }}>

will prevent the form from being submitted. (This is mostly equivalent to the suggestion onsubmit="return false;"

in the other answer.)



+1


source


I think the easiest way is to add onsubmit = "return false;" on the form element. Or with jQuery, preventDefault ();



I'm sure this isn't the best way, but it works!

0


source







All Articles