These are chat archives for canjs/canjs

2nd
Nov 2016
Gregg Roemhildt
@roemhildtg
Nov 02 2016 15:10
How can I prevent a form from submitting in a component when the enter key is pressed in canjs 3? Currently, I have
($submit)="noop" in the template and noop(){ return false; } in the viewmodel but the form is still being submitted.
Gregg Roemhildt
@roemhildtg
Nov 02 2016 15:47
It looks like the problems a little more complex than that. I can't seem to reproduce in a simple jsbin.
Nico R.
@nriesco
Nov 02 2016 16:04
@roemhildtg if you have “access” to the event you might use preventDefault (https://developer.mozilla.org/en/docs/Web/API/Event/preventDefault)
Gregg Roemhildt
@roemhildtg
Nov 02 2016 16:05
I think what's going on is an error is thrown somewhere along the line.
Then the return false isn't being executed and the page is redirected
Nico R.
@nriesco
Nov 02 2016 16:06
well you can try with a console log before the return line and see if it is executed
Gregg Roemhildt
@roemhildtg
Nov 02 2016 16:09
Just stepping through it... it looks like the return is being executed, but somewhere in a parent component its throwing an error. Its looking like something I'm doing wrong.
Gregg Roemhildt
@roemhildtg
Nov 02 2016 16:45
@nriesco you're right, preventDefault does fix the issue. :+1:
Nico R.
@nriesco
Nov 02 2016 17:03
Great!