spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

Ember error while creating dynamic routes


By the looks of it, you want to find the model from the parent route. You can do it likes so:

App.FavoriteRoute =
Ember.Route.extend({
   model: function(params) {
  
this.modelFor('favorites').arrangedContent.findBy('product_id',
params.product_id);
 }
});

UPDATE:

The problem is that your promise from the parent route isn't getting resolved correctly. You're returning a promise but the result of that promise isn't getting resolved i.e. (return data.favorites) is not resolving the promise.

Update it to:

App.FavoritesRoute =
Ember.Route.extend({
    model: function() {
      return new Promise(function(resolve, reject)
{
        Ember.$.ajax('yourURL').then(
          function(data){
            resolve(data.favorites); 
        });
    });    
  }
});

Also incorporate the initial feedback from this answer. I have a working JSBin going against an actual endpoint to show it works: http://jsbin.com/boloya/3/edit

P.S. Look out for params.product_id, that comes in as a string. You made need to cast it to the required type in order for the findBy to work correctly.

P.S.S. I should also add, Ember.$.ajax returns a promise, but you want the model to be data.favorites which is the need for the outer promise. If you just returned Ember.$.ajax and accessed everything via model.favorites you wouldn't need it.


Categories : Javascript

Related to : Ember error while creating dynamic routes
Ember Rails back button doesn't render template even without nested routes
Well, eventually, I ended up removing turbolinks. I am still a bit unsure about doing so, but it doesn't seem to hamper my application in any way yet. To do so, you would have to remove the turbolinks gem, the 'require turbolinks' line in application.js and the turbolink tags in application.html.erb. I'm crossing my fingers hoping that didn't mess anything up that I haven't seen.

Categories : Javascript
Emberjs: Accessing dynamic segment in nested routes/controllers
I think you're looking for route#modelFor. Example: App.Router.map(function() { this.resource('post', { path: '/post/:post_id' }, function() { this.resource('comments'); }); }); App.CommentsRoute = Ember.Route.extend({ afterModel: function() { this.set('post', this.modelFor('post')); } });

Categories : Ember Js
400 Error on certain routes (Django + gunicorn + nginx)
You are missing a semicolon after the server_name directive. Error 400 with nginx is usually related to a configuration error causing incomplete or wrong data being passed to the application. This hypothesis is reinforced by your statement that under apache it works fine. You should thus run gunicorn with a high log level (--log-level debug) and see what it gets passed by the web server. See the

Categories : Django
Trying to use jsonp with ember-data, and unable to use Ember App's store.createRecord in custom adapter
This parsing of the response seems more like a job for the RESTSerializer than the RESTAdapter(though you will still need the adapter if you need to set the dataType/url) Not 100% sure, but it looks like your reponse is an array that doesn't have the correct key as stated in the jsonapi.org documenation? If this is the case, you'd want to create a serializer for events like this App.EventsSeria

Categories : Ember Js
Ember can't find template when I provide a custom templateName to a View in Ember-CLI
In the Ember-CLI world, you want to use the ES6 import syntax, and supply your template to the View's template property: // app/views/my-view.js import Ember from 'ember'; import Template from 'app/templates/my-template'; export default Ember.View.extend({ template: Template });

Categories : Ember Js
Recently Add
Busy Indicator while page is loading
parent.document.getElementById and images path
Can not get bootstrap datetime picker to display properly
reading select box jquery issues
DC.JS Pie Chart + Select Deslect from external JavaScript function
Why would I ever need to cancelAnimationFrame()
Angular.ui alert doesn't close
HTML/JS How to position a rectangle relative to 'any' side of the parent canvas element
parse variable to xml
C# Dictionary equivalent in JavaScript
ExtJS Dashboard Panel Fit Panel Vertically
jQuery cross domain ajax call - Interpreted as script but transferred with MIME type text/xml
Reactjs map returns unexpected token }
Working with multiple pages in apache cordova and vs2013
Resize iframe to loaded content
Why 13596*0.1 is different than 13596/10?
AngularJS Validate all forms on application load
javascript open popup without menu/url/titlebar/scrollbar/anything
Can I use Razor syntax inside Javascript included in a ScriptBundle?
How to show a box for comment reply with id
parse name from user input when using jquery serialize
How to parse and load javascript object?
Marionette not navigating to the same url
Adding Google+ Sign in button to website
GRUNT - Install Grunt Packages?
how should I create the path of templateUrl property in Angular ui-router?
Update mysql database with jquery array using ajax
Run the same function on each item in a list / array
Get all ticks values (NVD3)
Button Click Event not Passing input String to MVC Controller Method
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.