I am using laravel and sammy.js for my application. My login form looks like this:
<form action="#/login" method="post">
<!-- inputs -->
</form>
Now, sammy.js catches it like this:
this.post('#/login',function(){
//handle, send to laravel for login
});
My problem is that if I press the enter key, apparently instead of submitting the form, which would result in this.post('#/login')
event to be catched and the function to be executed, an HTTP request is already made, and the laravel route is requested. As the route does not exist, a MethodNotAllowedHttpException
is thown.
Now, the question is: why does this happen? While pressing the "submit" button makes the login, hitting the enter key results in the error above.
I would like an actual solution to the problem, as well as an explanation of it, not patches like e.preventDefault()
on keypress or return false
in js.
Note: sammy is initialized correctly, the form is in the container on which sammy works and submitting using the enter key used to work in a previous version of the site. A lot has changed by now, so reverting is not a good option, so I would like an actual suggestion on how to solve the problem.
Thanks