{"id":2420,"date":"2022-08-30T15:24:43","date_gmt":"2022-08-30T15:24:43","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/01\/12\/problem-about-ember-old-router-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:24:43","modified_gmt":"2022-08-30T15:24:43","slug":"problem-about-ember-old-router-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/problem-about-ember-old-router-collection-of-common-programming-errors\/","title":{"rendered":"problem about ember-old-router-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4886b26d9b346a59b46c9af6a9c55f5c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nsly7_7<br \/>\nember.js ember-old-router<br \/>\nI&#8217;m trying to use an already instantiated controller in my ember route.Is it not normal to ever have instantiated a controller and want to use that in a route? I know that if I the application instantiate a controller for me, I can then to router.get(&#8220;myController&#8221;) but that won&#8217;t access one that I had instantiated myself. How do I get the piece of code at the bottom of my router to work?HTML&lt;script type=&#8221;text\/x-handlebars&#8221; data-template-name=&#8221;application&#8221;&gt;{{outlet}}&lt;\/script&gt;&lt;sc<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/74acfb86abc8570a1a5df3bc6e4b92bb?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAlexander Hauer<br \/>\nember.js ember-old-router<br \/>\nI have the following problem with ember.I have a table with a set of datas. I have an event that returns me the current element of the table. Then it opens another view by transitioning into a new state and writes the selected table data in a textfield.click: function(e) {var element = $(e.target).closest(&#8220;td&#8221;);App.tee = element.text().trim();var router;router = this.get(&#8216;controller.target.router&#8217;);router.transitionTo(&#8216;newRoute&#8217;)As you can see I have some other routes in my router as well. The<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4886b26d9b346a59b46c9af6a9c55f5c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nsly7_7<br \/>\njavascript asp.net-web-api ember.js ember-data ember-old-router<br \/>\nI&#8217;m currently trying to put something together with ember + emberdata + router + asp.net web api. Most of it seem to work, however I stuck in an error message I get when ember-data tries to findAll through the adapter for my models.In my backend I have a model like this (C#):public class Genre {[Key]public int Id { get; set; }[Required][StringLength(50, MinimumLength=3)]public string Name { get; set; } }Which in my app I represent it like this using ember-data:App.Genre = DS.Model.extend({id: DS<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4886b26d9b346a59b46c9af6a9c55f5c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nsly7_7<br \/>\nember.js ember-old-router<br \/>\nI have a nested route structure that allows for pagination \/ sorting \/ searching that will essentially tweak the ArrayController in some way. The problem I have with the current implementation is that everything is required to get a valid page to render.http:\/\/localhost:8000\/#\/page\/1\/sort\/username\/search\/daveIf I only pass the page I get the errorUncaught Error: assertion failed: Could not find state for pathAm I missing something in the nested routes or do I need to mark sort\/search as optional<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4886b26d9b346a59b46c9af6a9c55f5c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nsly7_7<br \/>\njavascript coffeescript ember.js ember-old-router<br \/>\nI&#8217;m trying to understand emeber.js routing. I&#8217;m not really sure, why this is not valid definition of routerPlatby.Router = Ember.Router.extend location: &#8216;hash&#8217; enableLogging : trueroot: Ember.Route.extendindex: Ember.Route.extendroute: &#8216;\/&#8217;initialState: &#8216;batches&#8217;enter: (router) -&gt; console.log &#8216;root.index&#8217;batches: Ember.Route.extendinitialState: &#8216;index&#8217;route: &#8216;\/batches&#8217;enter: (router) -&gt; console.log &#8216;root.index.batches&#8217;index: Ember.Route.extendroute: &#8216;\/&#8217;enter: (router) -&gt; console.log<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4886b26d9b346a59b46c9af6a9c55f5c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nsly7_7<br \/>\nember.js ember-old-router<br \/>\nAnyone have any ideas why I&#8217;m getting this error:Uncaught TypeError: Cannot redefine property: __ember1346884664897 when calling:App.get(&#8216;router&#8217;).send(&#8216;tags&#8217;)I&#8217;m making the call from one of my views, the router is in the correct state, and as far as I can tell I&#8217;m doing everything by the book.Would really appreciate any ideas&#8230;Created a gist that might help explain things a little better. https:\/\/gist.github.com\/3647288<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/428167a3ec72235ba971162924492609?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nYehuda Katz<br \/>\nember.js ember-data ember-old-router<br \/>\nI get this assertion when run the code below:Emptying a view in the inBuffer state is not allowed and should nothappen under normal circumstances. Most likely there is a bug in yourapplication. This may be due to excessive property changenotifications.Link to demo: http:\/\/plnkr.co\/edit\/s3bUw4JFrJvsL690QUMivar App = Ember.Application.create({Store: DS.Store.extend({revision: 4,adapter: DS.FixtureAdapter.create()}),Router: Ember.Router.extend({root: Ember.Route.extend({index: Ember.Route.extend({r<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4886b26d9b346a59b46c9af6a9c55f5c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nsly7_7<br \/>\nember.js ember-old-router<br \/>\nI have a fairly large example but the issue is that when I transition to the pagination route the first time -all is good. But if I try to click on another (kicking off the pagination event) I get the error belowI don&#8217;t have a jsfiddle because this is using ember-data and the objects are databound to my REST endpoint.The ember version is pre 1.0 using the latest ember-data + handlebars-1.0.0.beta.6 and jQuery 1.7.2Uncaught Error: could not respond to eventpaginateUsers in state root.paginated.H<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4886b26d9b346a59b46c9af6a9c55f5c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nsly7_7<br \/>\nember.js ember-old-router<br \/>\nRegarding the new Ember.js routing system (described here), if I understand correctly, views are destroyed when you exit a route. Is there any way to bypass destruction of views upon exiting a route, so that the state of the view is preserved when the user re-enters the route?Update: Looks like, views are not destroyed unless the outlet view is being replaced in the new route. For e.g., if you are in stateA with ViewA in some {{outlet master}} and you go to stateB with ViewB in {{outlet master}}<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4886b26d9b346a59b46c9af6a9c55f5c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nsly7_7<br \/>\nember.js nesting ember-old-router<br \/>\nI have the following code. (I&#8217;ll just copy the router, since the application has arround 500 lines at the moment) What I need, is to switch from state &#8216;rooms&#8217; to &#8216;guests.new&#8217;.When i get to rooms state, it loads a template where i call the action &#8216;newGuest&#8217; in order to change the state to the &#8216;newGuest&#8217; screen. But i can&#8217;t get it to work. On firebug I get this error:g[a] is undefinedHere&#8217;s the router code. Hope you can help me.App.Router = Ember.Router.extend({enableLogging:true,location:&#8217;hash&#8217;,g<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4886b26d9b346a59b46c9af6a9c55f5c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nsly7_7<br \/>\nember.js ember-old-router<br \/>\nI have a simple template that loops over a ember-data model. Inside the loop I want to provide a simple anchor tag that passes the id of the element along to the router so I can transition to another ember view. What I have below shows &#8220;undefined&#8221; in the href when I hover over the link, but when I log the content in the route it&#8217;s the ember-data model (not just the id as I&#8217;d like it to be).&lt;script type=&#8221;text\/x-handlebars&#8221; data-template-name=&#8221;session&#8221;&gt;{{#each session in controller}}{{sessio<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4886b26d9b346a59b46c9af6a9c55f5c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nsly7_7<br \/>\nember.js ember-data ember-old-router<br \/>\nI have compiled this example from various documentation and examples that I&#8217;ve found, but I haven&#8217;t found a complete example using a Router and ember-data to simply create a new record, so this is my whack at it. The Examplehttp:\/\/jsfiddle.net\/dmazza\/Hb6BQ\/4\/I have a person (DS.Model) with a firstName and lastName. I have a Router with index and create routes, where the create form appears in the outlet of the PeopleView. I&#8217;m using Ember.TextField&#8217;s bound to the attributes of a new Person create<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4886b26d9b346a59b46c9af6a9c55f5c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nsly7_7<br \/>\nember.js ember-old-router<br \/>\nI&#8217;m facing a problem with emberJS and the Router.My route architecture is the one below :rootindex apphome itemdisplay\/:id edit\/:idWhen I initialy navigate to display\/:id the URL is well written as below :localhost\/#\/app\/item\/display\/da083d21-afab-4620-8a85-6a4e6bfb95b9Then I hit the refresh button of my browser and the URL is then written as localhost\/#\/app\/item\/display\/undefinedI have the following functions in my route to handle serialize\/deserialize deserialize: function(router, context) {r<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4886b26d9b346a59b46c9af6a9c55f5c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nsly7_7<br \/>\ncoffeescript ember.js ember-old-router<br \/>\nI have a ember route that uses a date parameter to retrieve a collection of events. I am using the deserialize function to fetch the collection. After the collection is fetched the url changes from &#8220;\/day\/2012-10-08&#8221; to &#8220;\/day\/undefined&#8221;. The events include a range of dates so I can&#8217;t use the data to serialize the date parameter. Instead I should be able to return the params on the url. My example below sets an attribute on the router &#8220;current_params&#8221; on deserialize and returns it on serialize. I<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4886b26d9b346a59b46c9af6a9c55f5c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nsly7_7<br \/>\nember.js handlebars.js ember-old-router<br \/>\nI&#8217;m writing a simple sort \/ pagination controller using ember pre 1.0. I want to change the sort property on the controller when the user clicks a column header on the table. I have a simple action helper that points to my routers sortUser method but I can&#8217;t seem to pass in a raw string that the route can use as the param such as &#8220;username&#8221; or &#8220;id&#8221;Also my url seems broken (getting this url)http:\/\/localhost:8000\/#\/sort\/undefinedinstead ofhttp:\/\/localhost:8000\/#\/sort\/usernameThank you in advance&amp;l<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/68c381be021d82e1dfe938eaf3f77435?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nc4p<br \/>\nember.js ember-old-router<br \/>\nI am just starting with emberjs. I am creating a simple index.html page with two links on top: About and Posts. This is following the standard example on emberjs homepage. I get an error in the browser&#8221;Uncaught TypeError: Cannot call method &#8216;map&#8217; of undefined&#8221; So this means that my router is undefined. Why is that?Here is the app.js code:var App = Ember.Application.create();App.router.map(function(){});So I tried to define it &#8230;var App = Ember.Application.create();App.Router = Ember.Router.exte<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4886b26d9b346a59b46c9af6a9c55f5c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nsly7_7<br \/>\nember.js ember-data ember-old-router<br \/>\nI need to use two computed properties in the url of my app, but when make the transition they say undefined.Here is my code:App.PostController = Ember.ObjectController.extend({updated_at: null,year: function() { var updated_at = this.get(&#8216;updated_at&#8217;);return moment(updated_at).format(&#8216;YYYY&#8217;);}.property().cacheable(),month: function() {var updated_at = this.get(&#8216;updated_at&#8217;);return moment(updated_at).format(&#8216;MM&#8217;);}.property().cacheable() });App.Router = Ember.Router.extend({location: &#8216;<\/li>\n<\/ul>\n<p id=\"rop\"><small>Originally posted 2014-01-12 04:47:47. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>sly7_7 ember.js ember-old-router I&#8217;m trying to use an already instantiated controller in my ember route.Is it not normal to ever have instantiated a controller and want to use that in a route? I know that if I the application instantiate a controller for me, I can then to router.get(&#8220;myController&#8221;) but that won&#8217;t access one that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2420","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2420","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2420"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2420\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2420"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2420"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2420"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}