Reputation: 57
I'm working on a saved search feature for an Ember application, with the general idea being that after conducting a search you have the option to enter a shortname for the search and save it to localStorage
and retrieve it later from a dropdown list, while also being able to share the current URL with other users and have them see the same search.
This works through a combination of the Ember Router
handling search params in the URL and a view that handles the user clicking 'save' (the view is included in a fiddle, but is not able to be run as no templates are included -- see below).
Whenever I run the application, I get the following error:
Uncaught TypeError: Cannot call method 'set' of undefined
You can see the trace in the fiddle listed below, however it appears to stem from the controller store injection in ember-data. Unfortunately my knowledge of Ember[-data] doesn't extend far enough to know how this relates to the rest of the application.
I've taken the relevant parts of the application that should work independently and run them in a JSFiddle, but that still results in the same error. The fiddle is located at http://jsfiddle.net/fetcU/. Currently there are no handlebars templates or anything in that fiddle as they don't contribute to the problem.
The localStorage
adapter and other parts worked fine independently until the Router was introduced, and so it may be related to the code now being run by Checklist.initialize()
(which wasn't necessary until the Router was added).
I've compared this to other similar projects and examples, particularly those given for ember-data, and it's not entirely clear what I'm doing wrong here. I'd appreciate any insight!
Upvotes: 1
Views: 519
Reputation: 86
Did you try making your controller a class? So, instead of Checklist.savedSearchController, try Checklist.SavedSearchController.
Upvotes: 0
Reputation: 12011
First thing: When you create an app with a router, you don't have to create instances of Store, Controllers, Views. When calling App.initialize(), ember will do the instantiation and injection for you.
Then, you will have access:
Well, I let you try modifying the code. Let me now when you are stuck again :)
Upvotes: 3