Reputation: 6467
I tried reproducing the search field like they display at emberjs.com however for some reason my code keeps producing the following error (in google chrome) when entering a query and pressing either enter or clicking the submit button:
Uncaught Error: Nothing handled the event 'MyApp.ApplicationController.doSearch'.
The code I am working with can be viewed at http://jsfiddle.net/Mn2yy/
Can someone explain why this error is occuring and what I need to do in order to solve it?
Edit: for if the link goes down, these are the relevant parts of the code:
searchpage route:
MyApp.SearchRoute = Ember.Route.extend({
setupController: function(controller) {
controller.set('searchQuery', this.get('query'));
},
renderTemplate: function() {
this.render('searchpage', { into: 'container' });
}
});
Applicationcontroller:
MyApp.ApplicationController = Ember.Controller.extend({
// the initial value of the `search` property
search: '',
doSearch: function() {
// the current value of the text field
var query = this.get('search');
this.transitionToRoute('search', { query: query });
}
});
and the template:
<script type="text/x-handlebars" data-template-name="container">
<button {{action "doSearch" target="MyApp.ApplicationController"}} rel="tooltip-bottom" title="search" class="icon"><i class="icofont-search"></i></button>
{{view Ember.TextField valueBinding="MyApp.ApplicationController.search" action="MyApp.ApplicationController.doSearch"}}
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="searchpage">
<h1>Search</h1>
{{#linkTo "home"}}Homepage{{/linkTo}}
<p>You searched for: "{{searchQuery}}"</p>
</script>
Upvotes: 0
Views: 1375
Reputation: 1134
You shouldn't use absolute paths for bindings, targets etc. like MyApp.ApplicationController.search
.
Since you declared both the search
property and the doSearch
action on the application controller, just simply type: {{view Ember.TextField valueBinding="search" action="doSearch"}}
Upvotes: 2