Reputation: 1882
I'm trying to create a submit action on a register form. here is my register handlebar:
<form class="form-signin" {{action "register" on="submit"}}>
{{input class="form-control" value=username type="text" placeholder="Username"}}
{{input class="form-control" value=password type="password" placeholder="Password" }}
<button class="btn btn-lg btn-primary btn-block" type="submit">Register</button>
</form>
here is the router:
import Ember from 'ember';
import config from './config/environment';
var Router = Ember.Router.extend({
location: config.locationType
});
Router.map(function() {
this.resource('register', {path: '/register'});
});
export default Router;
and here is my register controller:
import Ember from 'ember';
export default Ember.Controller.extend({
register: function(){
return 'hello';
}
});
when I submit the form I get this error:
Uncaught Error: Nothing handled the action 'register'. If you did handle the action, this error can be caused by returning true from an action handler in a controller, causing the action to bubble.
what am I doing wrong?
Upvotes: 0
Views: 135
Reputation: 1882
I was missing the action property in the controller. It should look like this:
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
register: function(){
alert('hey');
}
}
});
Upvotes: 1