FAQ Database Discussion Community


Ember Data: CreateRecord not updating model when using store.find with query params

ember.js,ember-data
When my route model uses this.store.find('user') it updates automatically and the template shows new records created using createRecord. So the following works as expected: Route: model: function(){ return this.store.find('user'); } Template: {{#each user in model}} {{user.username}}<br> {{/each}} Controller Code: // Triggered when form submitted to create a new user var...

What is the point of the .save() function in ember data?

ember.js,ember-data
What extra utility does .save() serve? I don't understand why changes to a model aren't saved until you call this function. Is there a reason you would ever not save changes?

Sorting data by timestamp on ember

ember.js,ember-data,ember-cli
I've looked at a few examples, but haven't been able to reverse-sort, so that newly generated objects are on top. My sortable items are in components, and I don't think I'm passing sortProperties & sortAscending correctly. lavender.js: export default Ember.Controller.extend({ needs: ['application'], sortProperties: ['timestamp'], sortAscending: false }); lavender.hbs {{#each model.comment...

Ember.js execute action when clicking browser back button

ember.js,ember-data
I need to execute an API call when user clicks on the back button in the browser and then redirect to a route based on backend response. I've read about location API but I can't figure out how to distinguish between url changes due to clicks on link and url...

Retrieving model's property in controller

ember.js,ember-data
I have a model which contains a single data but it's inside an array. I want to retrieve this data from inside my controller and making it a property of the controller so I can use it in other controllers. For example : App.CurrentsubuserController = Ember.ArrayController.extend({ currentsubuser: function() { return...

Ember Two-way data binding with parser

ember.js,ember-data
I'm new to ember—loving it so far. I'm using Ember-data, and I have an attribute that needs to contain some structured JSON. However, I want to use a textarea to edit this attribute. The textarea should not display the JSON "as JSON" but according to some other arbitrary criteria. For...

How can I know which item in a handlebars each loop triggered a function in my Ember controller?

ember.js,ember-data,ember-cli,handlebars
I am new to Ember, and I am trying to set up a list of folders. When you click on the icon next to a folder, it will load (i.e. find('folder', folder_id) ) the child folders. If the top level folder has 16 sub-folders, I am trying to set a...

Model object not preserved when using hash for model in ember route

javascript,ember.js,ember-data,ember-cli
EDIT: I've set up an actual repro of the issue on JSBIN Been trying to resolve this for a while now and I'm clearly not understanding how the relationship between model and setupController works. I have a model which is returning a hash; the result of two find calls: model(params)...

Getting length of hasMany association

ember.js,ember-data
I have the following Models defined in my Ember project (project created with ember-cli 0.2.3) import DS from 'ember-data'; var Game = DS.Model.extend({ title: DS.attr('string'), description: DS.attr('string'), geekRating: DS.attr('number') }); Game.reopenClass({ FIXTURES: [ { id: "1", title: "Catan", description: "Catan the game", geekRating: "5.65"} ] }); export default Game; import...

Adding view dynamically inside template Ember Js

jquery,ember.js,ember-data,handlebars.js
On click of a button i want the following to be added dynamically inside a template. {{view App.DatalistText type="text" value=test class="form-control" placeholder="Start Typing" list="names" size="50" }} <datalist id="names" value=te> {{#each model}} <option {{bindAttr value=name}}> {{/each}} </datalist> There is a div <div id="container"></div> When user clicks a button contents of div...

Does ember-data subsequent find generates XHR every time without caching?

ember.js,ember-data
I have an app built using ember-cli 0.2.5 (which is Ember 1.12.0 and Ember-Data 1.0.0-beta.17). My models' store.find() always generate XHR request to my backend. I would expect subsequent route accesses to use the store's cache. I have two routes, router.js is: Router.map(function() { this.route('rules', {path: '/rules'}); this.route('users', {path: '/users'});...

Ember Data: (best practice) Dynamic Parameter for find()

ember.js,ember-data
maybe it's just a brain bug on my side, but im really confused for many days now. I have a search formula with many configurable changing parameters like this: ID, name, lastname, date1, There is no hierarchical order of these parameters, the user can configure them in and out of...

store.find in IE9 is not working

ember.js,ember-data
I can't seem to fetch new data in Internet Explorer 9. For the purpose of an example I test the store this way: App.__container__.lookup('store:main').find('style') The only error I receive is the following: SCRIPT5022: Error: Assertion Failed: [object Object] Does Ember-data works out of the box (without polyfills, ...) in Internet...

posting a special command on an ember model

ember.js,ember-data
I have a ember-data model called session. The API server (cannot change it) doesn't support POST command to update the entire model (so I can't just call .save() I want to be able to change a property called editedStatus. The way the API server is allowing me to do it...

Reloading route after .save()

ember.js,ember-data
I want to reload a route after a .save() (in controller). Currently, ember-data is changing the status in the store but whatever I tried for reloading the route didn't work. The problem is I want to reload the current route based on conversation status. For example, if I'm currently in...

JSON Expectations for Ember Data Polymorphic Relationships

json,ember-data,polymorphic-associations
DEBUG: Ember : 1.8.1 ember.js:15373DEBUG: Ember Data : 1.0.0-beta.18 ember.js:15373DEBUG: Handlebars : 1.3.0 ember.js:15373DEBUG: jQuery : 1.11.3 So I have a "Request" model which can depend on an account or other Requests that stand in for and account when it is fulfilled. I'm a bit confused about how to get...

Iterate through fixtures in a template

ember.js,ember-data
I'm using ember-cli and Ember v1.13.0-beta.1 and I have the following model, route and template. models/products.js import DS from 'ember-data'; var Product = DS.Model.extend({ title: DS.attr('string'), ... }); Product.reopenClass({ FIXTURES: [ { id: 1, title: 'Title', ... } ] }); export default Product; routes/products.js import Ember from 'ember'; export default...

Cannot set property 'all' of undefined

javascript,ember.js,ember-data,jsonserializer
I'm having a problem getting a response form an API in my Ember.JS application. I'm using a "dummy" API just to learn Ember with and I didn't feel like creating my own back end (this one specifically). Whenever I try to navigate to the Posts template I get the following...

Ember error on refresh

javascript,ember.js,ember-data,ember-cli
I have a very simple toy app using Rails as an API and Ember 1.8.1 with CLI for the client. I have a typical sidebar setup where when you click the item, it displays next to the list. Everything works fine until you refresh the page with a list item...

Create ember-data record outside of store

ember.js,ember-data
I am very new to Emberjs. I would like to create a temporary instance of a model (Customer) for use in my "customer.create" route. However I don't want it to be added to the store. Is there a way to do this? Currently I am doing this: model: function(){ return...

Cannot read property 'match' of undefined at Ember.DefaultResolver.extend.podBasedComponentsInSubdir

ember.js,ember-data,ember-cli
I'm getting a really opaque error message (opaque in the sense I have no point of reference for my own source) from console, I'm not entirely sure where to look, I feel it's likely an error in library code but before posting this on github I'll just double check it's...

RESTAdapter vs Localstorage. Why should I switch to RESTAdapter?

ember.js,ember-data
I've been working with Ember for several months now. Our project had to run offline so we used App Cache and Ember Localstorage Adapter. I've become very comfortable with this approach. We load all data at once from the server and then use it throughout the project's Routes. Currently we...

How can I display a specific view in the main application template with EmberJS

javascript,ember.js,ember-data
Begginer with EmberJS, I am wondering how can I display a specific view in my main template ? When I click on the menu in application.hbs I want to display User,Event What is the best practice, using component ? moddal views ? Do you have any good tutorial ?...

Ember: Access ember data 'store' object from utility class

javascript,ember.js,ember-data,ember-cli
I have a utility class for validating usernames in my ember application and have it setup as specified in the ember-cli docs. I do client-side username validation in several places in my application (components and controllers) so I wanted to pull the validation logic out into a reusable method. The...

How dynamically load route in EmberJS?

ember.js,ember-data
Need on change search field - load route with params /search/WORD, path of route, example, /search/:q How is best way? In template {{input value=str}} and in controller this.transitionToRoute('search', this.store.find...) . It require loading model in controller and duplicate to route mode:function(){ return this.store.find...}. In controller call route by url this.transitionToRoute('/search/'...

Ember serialize embedded record with custom key

ember.js,ember-data
I've a model with store attribute in it. Unfortunately store is a reserved word in ember-data so I had to change its name to authStore. I can't change backend API to use new attribute name, so I've created a new serializer just for this model. Model is: App.Auth = DS.Model.extend({...

DS FixtureAdapter error Undefined for Ember JS

html,ember.js,ember-data
I keep getting DS.FixtureAdapter Undefined error. I am Not sure how to fix this error. I am getting the error on the line with App.PersonAdapter = DS.FixtureAdapter.extend({}); Here is app.js code. App = Ember.Application.create(); App.Router.map(function() { // put your routes here }); App.PersonAdapter = DS.FixtureAdapter.extend({}); App.Person = DS.Model.extend({ firstName: DS.attr(),...

Ember select default value

javascript,ember.js,ember-data
I am unable to select a default value in an ember select. Here is what the code looks like Models: rfwa.Field = DS.Model.extend({ Name: DS.attr('string'), FieldTypeId: DS.attr('number'), FieldType: DS.belongsTo('fieldType'), }); rfwa.FieldType = DS.Model.extend({ Name: DS.attr('string') }); Route: rfwa.FieldRoute = Ember.Route.extend({ model: function (params) { var route = this; return Ember.RSVP.hash({...

Model Property Binding in Ember / Ember-Data

ember.js,ember-data
Is there a recommended approach or pattern to the following application flow? User enters a route Model for route is retrieved and presented to the user via the template. The template inputs are bound to model properties so as the user modifies them, the data in the store is updated...

emberjs with laraval pagination

laravel,ember-data,ember-cli
I am beginner with emberjs. I am trying to load a paginated data, so far able to load the whole records. Now not sure how to load the laraval paginated data, as when i send call without pagination i get response like { 'users':[{ 'id':1, 'name':'Aamir' },{ 'id':2, 'name':'Jamshed' }]...

What's the best way to map objects into ember model from REST Web API?

json,rest,ember.js,asp.net-web-api,ember-data
The topic of this post is: my solution is too slow for a large query return. I have a Web Api serving REST results like below from a call to localhost:9090/api/invetories?id=1: [ { "inventory_id": "1", "film_id": "1", "store_id": "1", "last_update": "2/15/2006 5:09:17 AM" }, { "inventory_id": "2", "film_id": "1", "store_id":...

Fetching API data from Ember Controller

ember.js,ember-data,ember-cli
I am an Ember newbie and am trying to create a simple application to fetch records from an API server. Currently I am trying to query the this.store.find('validemail',{'email':'abc.gmail.com'}).then(function(response){ console.log(response); }); //Console log on browser Class {query: Object, store: Class, manager: Class, isLoaded: true, meta: Object…}__ember1434866946710: "ember592"__ember_meta__: Object__nextSuper: undefinedcontent: (...)get content:...

Cannot get Rails REST API to work with Ember.js

ruby-on-rails,ember.js,ember-data
I'm busy following this Ember.js tutorial, but I'm trying to implement it using the Ember 2.0 way of doing things (modules, using Ember CLI and the ember-cli-rails gem). It's rather difficult since none of the Ember guides follow these conventions. As per the tutorial, I'm using Rails as a JSON...

How do I return the result of Ember.RSVP.all from a function?

ember.js,ember-data
The function below needs to return a true or false. Inside the then call at the bottom of the function, I get the value I need from result.isAny('hasOverride') but I don't know how to return this value from the hasRoomUpcharge function. How do I do this? I thought adding return...

Inserting external parameter in map function with ember

ember.js,ember-data
I have this function: this.get('model').map(function(item){ if(item.get('isSelected')){ item.set('selectedClass', 'conversation-history'); } }); What I would like to do : this.get('model').map(function(item){ if(item.get('id') == this.get('selectedConvId')){ item.set('selectedClass', 'conversation-history'); } }); This tells me this.get is not a function, and I understand why, I am not in the same scope. But how can I introduce an...

How do I add parameters to an Ember Data save for specific models?

ember.js,ember-data
What I'm looking to do is add parameters to an Ember Data save for for specific models. The parameters I'm looking to add will come from and ajax call to my Grails back-end, to generate a token for CSRF mitigation. One of the parameters will be the URL that will...

Ember.js REST Adapter use JSON root(use ember-data)

javascript,json,ember.js,ember-data
The Ember.js REST Adapter expects the JSON to be returned as: { "customer": { "CustomerID": "ALFKI", "CompanyName": "Alfreds Futterkiste", "ContactName": "Maria Anders", "ContactTitle": "Sales Representative", "id": "b0d16ed0-c901-4ca3-ba41-7fc74c96909f" } } But my API returns the data without a root element: { "CustomerID": "ALFKI", "CompanyName": "Alfreds Futterkiste", "ContactName": "Maria Anders", "ContactTitle": "Sales...

Ember.js - Rendering additional data for a model

javascript,ember.js,ember-data
I have an app model and apps have an id and name. this.resource("apps", function() { this.route('show', { path: ':app_id' }); }); I'd like to make the show view show metrics about the app, but the query is pretty intense, so I don't want to include it in the call to...

Custom API calls with Ember Data

ember.js,ember-data,ember-cli
I don't know if this is possible with Ember data, although I am kind of doubtful, but the API I am working with supports being able to produce 'or' queries by hitting URLs like, /v1/subjects?first_name||last_name=*dr* this would result in a query that looks like select * from subjects where first_name...

How to serialize Ember-Data

json,ember.js,ember-data
I need to serialize Ember-data to JSON and use the JSON to feed this JS Library: http://www.jstree.com/docs/json/ I don't how to achieve this. DS.RESTSERIALIZER with DS.EmbeddedRecordsMixin should be able to achieve this but I dont know how to call them in my Ember-CLI app. They seem to be built to...

ember-data and get function to dig into async models is not working

ember.js,ember-data
i prepared a jsfiddle sample: https://jsfiddle.net/6Evrq/503/ I get a ember-data model "RegisteredFighter" and want to access on that model the "RegisteredFighter" property. then i get an object with and all the other ember-data properties: { id: "3" _data: { id: 3, Fighter: 3, FightRule: 1, WeightClass: 1, FightClass: 1 }...

configuring server and client ports in Ember-Cli

ember.js,ember-data,ember-cli
I am making an Ember app using Ember-Cli which talks to a server side application. Because Ember-Cli projects run with their own server (on port 4200 by default), I have to run my server in development on a different port (localhost:8080) than the Ember app. In production, however, the two...

Ember Data async hasMany not loading in production

ruby-on-rails,ember.js,ember-data,ember-cli
My Ember CLI app is using Ember 1.10.0 and Ember Data 1.0.0-beta.15. It's also running inside a Rails app via the ember-cli-rails gem. I have various models with hasMany associations, all of which are marked async: true. In development, when these associations are needed, the app fires a query to...

FirebaseAdapter not recognized on my Ember app

ember.js,ember-data,firebase,emberfire
I'm trying to use Firebase with my Ember app. I installed Emberfire but my app returns Uncaught TypeError: Cannot read property 'extend' of undefined Because it doesn't read 'FirebaseAdapter' App.ApplicationAdapter = DS.FirebaseAdapter.extend({ firebase: new Firebase('https://glowing-fire-number.firebaseio.com/') }); I checked if Ember data is being loaded before Firebase and EmberFire too. Here...

Ember Data “modelFor” error when serializing models

ember.js,ember-data,ember-cli
I am using ember 1.13, ember-cli and ember data 1.19.1 and I am experiencing an error that is difficult to track down due to being unspecific. The error occurs when I do the following: this.get('model').forEach(function(mymodel) { applications.push(elavonApplication.serialize({includeId: true})); }); where "elavonApplication" is an instance of a DS.Model called "elavon-application" and...

Uncaught Error: No model was found for 'model'

ember.js,ember-data
I'm building an Ember-CLI app using the following: DEBUG: Ember : 1.10.0 DEBUG: Ember Data : 1.0.0-beta.15 DEBUG: jQuery : 2.1.3 Using a form, I'm trying to save changes on 2 separate models. One of the models (the user model) saves successfully, while the other (profile model) throws this error:...

Ember Data One to One Relationship Record Creation Fails

json,ember.js,ember-data,ember-cli
I receive the following error when I use Ember Data to create records from a JSON response. What gives? I am following what the docs state. Uncaught Error: Assertion Failed: Ember Data expected a number or string to represent the record(s) in the `user` relationship instead it found an object....

adding toplevel json namespace (or model name) in extractArray

ember.js,ember-data
I have an Ember app with a Product model. My server response is json like this (for one entry) { "id": "a01dfaa0", "type": "computer", "cost": "0.50" } or an array of such objects [{ "id": "6b2360d0", "type": "fridge", "cost": "2.50" },{ "id": "a01dfaa1", "type": "car", "cost": "5.95" }] In other...

EmbeddedRecordsMixin not working as expected, what am I missing?

ember.js,ember-data,ember-cli
I'm trying to use embedded records in ember data and I think I'm missing something fundamental. I have two models app/models/video.js: export default DS.Model.extend({ title: DS.attr('string'), transcriptions: DS.hasMany('transcription', { embedded: 'always' }) }); app/models/transcription.js: export default DS.Model.extend({ video: DS.belongsTo('video') }); I also have a custom serializer app/serializers/video.js: export default DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin,...

Ember-data cannot read property 'length' of undefined

javascript,jquery,ember.js,ember-data
I'm trying to get data from api server with ember-data ,i added ember-data to ember starter-kit. Getting with App = Ember.Application.create(); App.Router.map(function() { // put your routes here }); App.ApplicationAdapter = DS.RESTAdapter.extend({ namespace: 'emberjs/ember.js', host : 'https://api.github.com/repos' }); App.Store = DS.Store.extend({     adapter: 'App.ApplicationAdapter' }); App.IndexRoute = Ember.Route.extend({ model: function() {...

Model from Ember Data not rendering

javascript,ember.js,ember-data
I'm trying to figure out how to fetch data with Ember Data and render. After several problems I got to this point where I get no error on the console but the store is empty after the data is loaded. window.App = Ember.Application.create(); App.IndexRoute = Ember.Route.extend({ model: function(){ return this.store.find('games');...

How is Sorting achieved in an Ember model without using Array Controller?

ember.js,ember-data,ember-cli
Every google result is about an ArrayController sorting. Need a sorting mechanism without using ArrayController. There is a model where there are sort params. Like say 'sortOrder' as one of the properties in the model (which will be from a back end). Will be rendering this model using #each but...

Ember Data TypeForRoot no longer being called

ember.js,ember-data
We are currently on Ember Data 1.0.0-beta.18, Ember 1.12 and CLI 0.2.7. Since this last update, we are getting ember data assertion warnings like the following: [Warning] WARNING: Encountered "open_requests" in payload, but no model was found for model name "open-request" (resolved model name using [email protected]:appuser:.typeForRoot("open_requests")) (vendor.js, line 15423) I...

Set an Ember.js controller variable to an Ember Data object, not a promise

javascript,ember.js,ember-data,promise
I have a route that initially has no suggestion. Based on an action, I would like to grab a suggestions array with Ember Data, get the first suggestion and assign it to the controller. Here's what I've got: App.IndexRoute = Ember.Route.extend({ setupController: function(controller, model) { this._super(controller, model); controller.set('suggestion', null); },...

Ember custom model save

ember.js,ember-data
In my application I have a model post, it has properties user_likes and user_shares, a user can share and like a post of course... a save action results in a PUT for /posts/:id with post as payload, but in my webserver shares and likes have different store strategies, and I...

Create a record from related “belongs to” route. Assertion failed: Assertion Failed: You can only add a 'group' record to this relationship

ember.js,ember-data,ember-cli
I'm trying to create a new "student" from within the "group" route. The "student" belongs to the group. True to form, as soon as you want to do anything different to the very straightforward examples, things become a total mystery - I'd appreciate some help! "Students" belong to a "Group"....

Ember: Merge Multiple Column of Arrays to rows

javascript,arrays,ember.js,ember-data
I have to populate a grid in which each column's data comes as a array under the object as mentioned below where A and B are column names and data structure as follows { A:[1,2,3], B:[4,5,6] } So to render this as a table in template it will be easier...

Connect to a RESTful service which ends all URLs with an “/”

ember.js,ember-data
I have to connect to a RESTful service that ends every URL with an "/". The list of products is at http://company.com/api/products/ And the product with the ID 1 is at http://company.com/api/products/1/ This is my current app/adapters/products.js import DS from 'ember-data'; export default DS.RESTAdapter.extend({ host: 'http://company.com', namespace: 'api' }); Is...

Security problems in upgrading ember application

ember.js,ember-data,ember-cli,content-security-policy
I have an ember/ember-cli application that I am upgrading from 1.10 to 1.12. This application uses an API that runs on port 8000 in development. I have the following environment.js: module.exports = function(environment) { var ENV = { modulePrefix: 'myapplication', environment: environment, baseURL: '/', locationType: 'auto', EmberENV: { FEATURES: {...

how to add event for drop-down component to change subdomain by selected item

ember.js,express,ember-data,subdomain,ember-cli
i use pod structure with ember cli. i have a 'drop-down' component. in my drop-down.js component: import Ember from 'ember'; var component = Ember.Component.extend({ tagName: '', //remove extra div wrapper. valueKey: 'id', textKey: 'text', options: [], value: null, defaultText: 'select...', selected: function () { var valueKey = this.get('valueKey'); var textKey...

Difference between this.get('model') and modelFor

ember.js,ember-data
I am quite new to ember and don't really get the difference between two types of syntax. Where and in which situations should i use one or another. I.e. Which one is more suitable for usage in Routes and which one for Controllers. this.get('model') As opposed to this.modelFor('artists/show') ...

How to use an array of strings to refer to a subset of model properties in Ember?

ember.js,ember-data,htmlbars
I'm trying to put a property in my Ember(ember-data) models that is just an array of the properties to include in a generic table component. At first I just added this to my models: tableColumns: function() { return ['age', 'gender', 'whatever']; }.property() But now I find myself jumping through hoops...

How to accept model collection metadata, such as count in ember?

ember-data,ember-cli
In Ember-CLI, how does one go about retrieving/storing model collection metadata? For example, suppose I have a model 'user' with some defined attributes, and my route retrieves a collection of users with ember-data like so: model: function(params) { return this.store.findQuery('user', params); } }); and the JSON response from my API...

Getting the model inside a controller emberjs

javascript,ember.js,ember-data
I need to get the grand total price of all the objects returned from a JSON API. my idea is to create a controller and set a property on it. Then grab the model loop over each object and add to the predefined property that objects total price. Something like...

How to run action in Ember Controller afterRender

ember.js,ember-data,ember-cli
im new to ember framework. I just want to execute a function that defined inside the actions hook when the rendering completes. var Controller = Ember.Controller.extend({ actions: { foo: function() { console.log("foo"); } } }); Ember.run.schedule("afterRender",this,function() { this.send("foo"); } but the above code not working. I just want to know...

Ember Routing Model Observing Updates in Handlebars Template

ember.js,ember-data,ember-cli
How do I update a model property once a promise (via Ajax call) has returned? Here is my go at it that is not working. In the docs, it appears observing takes place using Ember.set but the model I am returning is not an Ember model object so I don't...

Ember Handling 401s Revisited in 2015

ruby-on-rails,ember.js,error-handling,ember-data
I can find a ton of old questions asking/answering how to handle 401s from the Rails backend in Ember/Ember Data. Many, if not all, seem to be outdated at this point. I have tried everything I could find. (Ember-Data handling 401’s) But no matter what I do I just keep...

ember-data stores a string instead of a number

ember.js,ember-data
In my ember app I want to reuse a model attribute as soon as the form is submitted. But the store seems to keep it as string unless I reload the whole route. I am using this and the following components: Ember : 1.12.0 Ember Data : 1.0.0-beta.18 jQuery :...

Ember.js: Loading related models directly

ember.js,ember-data,ember-cli
I dont understand how ember loads related models. Lets say thats my model: export default DS.Model.extend({ title: DS.attr('string'), description: DS.attr('string'), states: DS.hasMany('state', {async: true}) }) I load this on of my outer routes. When navigating though an ember-app (into nested routes), model-contexts are often provided for routes not by the...

Defining buildURL depending on what properties have changed

ember.js,ember-data
I would like to redefine my buildURL depending on what properties changed on the same model. For example, if the status changed, I would like to PUT to a certain route, and if the subuser changed, I would like to PUT to another route. Example : this.store.find('conversation', conv.id).then(function(conversation){ conversation.set('status', 'opened');...

Ember.js binding to and saving belongsTo property

ember.js,ember-data
I have two models related to one another via belongsTo (a reciprocal relationship, i.e. 1:1) utilizing the async property. Having retrieved one record and setting it to the Model on the router, I have access to the properties in the main record and its associate—everything works fine there. I've used...

emberjs resetting a routes model

ember.js,ember-data,ember-cli
I want to reset a model on a route after a user clicks the sort header on a table: import Ember from 'ember'; //import _ from 'lodash'; export default Ember.Route.extend({ needs: 'event-profile', model: function(){ var parentmodel = this.modelFor('eventProfile').get('slug'); return this.store.find('listingEvent', { eventInstanceSlug: parentmodel, skip: 0, limit: 20 }); }, actions:...

Rolling back a model after failed delete doesn’t update view

ember.js,ember-data
I'm trying to catch and handle a failed delete request by rolling back the model and having it remain in the view, but I'm having problems. I've got the following in my controller's delete action: model.delete(); model.save().then(function() { alert('Deleted!'); }, function(err) { alert('Delete failed...'); model.rollback(); }); This seems to work...

ember nested route not loading

ember.js,ember-data,ember-cli
Just trying to determine how to do this. For an image sharing site I have the following requirement. User is able to view an image User is able to comment on the image User is able to see comments from users friends on the image this is my router.js: this.resource('image',...

Emberjs: Save persistent data from remote API to local storage

javascript,ajax,ember.js,ember-data
I am still a little confused about the way Ember fetches data from remote API and save them in the browser. So I have created a REST Adapter to get sets of records with an Ajax call, a serializer, and the corresponding model. Suppose they are posts, and I have...

Ember - Nothing handled the action occurs

ember.js,ember-data,handlebars.js,ember-cli,handlebars
Nothing handled the action error occurs for the following code. How to resolve this? I have created a view, an object for my sample app using ember. But the action part is not working. How to bind an action to a view? HTML: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Ember...

Ember CLI path based on server response

ember.js,ember-data,ember-cli
I'm developing a substantial ember app, using Ember CLI, and I'm struggling with a few aspects of it. What I want to do is: Show a dropdown list of options When the user picks an option, post their choice to the backend The response from the server contains data based...

ember-cli migration: global app module import

javascript,ember.js,ember-data,ember-cli
I'm having some slight ember-cli migration difficulties with the global application variable. In project/app/app.js I define App as: var App; Ember.MODEL_FACTORY_INJECTIONS = true; App = Ember.Application.extend({ modulePrefix: config.modulePrefix, podModulePrefix: config.podModulePrefix, Resolver: Resolver }); Then in a separate controller, project/app/controllers/auth.js, I attempt to access App using the following statement: import Ember...

accessing Ember data store from a controller / multiple data on model hook

ember.js,ember-data
I have a model hook that returns a list of reviews from the data store. On that same page, I have a review form. When the form is submitted, I call an action on the controller and I need to call createRecord() on the store. Normally I would pass a...

Embjers store.createRecord or store.push not updating view

ember.js,view,ember-data,push
I'm trying to create a new record and push it into the store. I can persist it just fine (and i'll push to the store after successfully persisting, once i figure this out), but the view/template isn't being refreshed. I know persistence works because, if I refresh the entire page,...

Ember self-reference and polymorphism

ember.js,ember-data
there is a user model which also relates to itself as contact so user has_many contacts. Than each contact has and belongs to many "groups". Both user and contact has one address. I read through http://lukegalea.github.io/ember_data_polymorphic_presentation/#/ couple of times, but yet still do no understand how to setup { user...

Model not being saved (Fixtures)

ember.js,ember-data,fixtures
my recors are not being saved to the database after being created. I'm just using fixtures. I can see the model on the Ember addon when creating it in the form, but after hitting save, they dissappear and nothing happens. Also, when I select an item on the model.genre select...

EmberJS / Ember-Data: 404's Not Getting Caught

ember.js,ember-data
I am trying to catch 404 errors in my ember app, and redirect to /not-found. I have an errors action on my ApplicationController, and I have an RSVP.on('error') function too but the 404's aren't getting caught. I just get a 404 error thrown to my console from jQuery, but the...

Ember view doesn't update after store.unloadAll if single item is in model

ember.js,view,model,ember-data
All records are unloaded from the store, but it doesn't change in view when single item is shown. If multiple items are shown, everything updates correctly. live example: http://emberjs.jsbin.com/mojase/2/edit?html,js,output singleItem should also disappear when all items are unloaded, but it doesn't....

sortable list in emberjs

ember.js,ember-data,handlebars.js
i have loaded a list from server into handlebar. when the list order changes, i need to send the sorted order back to the server. to make a list sortable, i have used jquery-ui.js. when i change the list order by dragging and dropping the list, visually the list order...

Computed Property not working

ember.js,controller,ember-data,computed-properties
I'm writing the todo app and I can't get computed properties working. I want to implement computed properties in the todos/index controller so that the template can appropiately display the amount of todos undone remaining (based on the isCompleted attribute of the models). This is the code: todos/index.hbs {{input type="text"...

Working with Embedded Records and Ember Data

javascript,json,ember.js,ember-data
I am working with Ember and Ember Data, and the JSON I get back from the server contains an embedded object array. I need to know what I am doing wrong. I have a JSBin with the code below: http://emberjs.jsbin.com/faledu/6/edit?html,js,output Currently, I am getting the following error: Error while processing...

Mapping Ember methods to API

ember.js,ember-data,rails-api
I'm using Ember Data with a Rails API and am wondering how I can map specific actions from Ember to the API. For example, in looking at the Ember docs for deleteRecord and destroyRecord I see no mention of how these methods are translated to the backend. Is this configured...

Ember.js: select state not saved in URL when reload page

select,ember.js,ember-data
There are select on the page for choosing country and it's need to save selected value in URL. I declared query params in route-driven controllers. It's all work! If country select is changed then url also changed. Demo: http://output.jsbin.com/releza But if I reload page with some valid GET params then...

Where did my data get stuck in Ember?

ember.js,ember-data,ember-cli-mirage
I'm trying to learn ember but having a hard time finding out why my data from the backend is not showing up. I'm using Ember Data with mirage fixtures. The data is showing up. Only if I introduce simple relationships the data from those relationships is not showing up in...

Using ember-data with custom serializer

javascript,ember.js,ember-data,ember-cli
I have you could say a non standard json api. I'm trying to use ember-data with it so from my reading around I need to create a serializer. I tried to find article online explaining how to do this but haven't found anything useful. I tried looking through the ember...

Ember data, relationships and JSON

javascript,ember.js,ember-data
I have the following JSON being returned from an API: { "project": [ { "id": "1", "name": "My First Project", "owned_by": "1", "updated_at": { "date": "2015-05-06 15:46:27.000000", "timezone_type": 3, "timezone": "Europe/London" }, "created_at": { "date": "2015-05-06 15:46:27.000000", "timezone_type": 3, "timezone": "Europe/London" } } ], "subscriptions": [ { "id": "10", "output":...

Observing RecordArrays in EmberJS

ember.js,ember-data
I have this setup right now: App.Workspace = Em.Object.extend({ users: null, usersChanged: Em.observer('users',function() { console.log('Users Updated!'); }), ... initListeners: function() { var self = this; someObject.on('someEvent', function() { ... console.log('before set'); self.set('users', self.store.all('users')); }); } }); I only get the output "before set", but not "Users updated!" What am I...

Access and Update a Fixture Ember JS

ember.js,ember-data,fixtures
How can I update/edit a specific Person in IndexController? App.Person=DS.Model.extend({ name:DS.attr('string'), iminus:DS.attr(), iplus:DS.attr() }); App.Person.FIXTURES=[ { id:1, name:'M', iminus:[{amount:50,pers:'A'}], iplus:[] }, { id:2, name:'An', iminus:[{amount:20,pers:'Mo'}], iplus:[] } ]; App.IndexRoute=Ember.Route.extend({ model:function(){ return this.store.findAll('person'); } }); App.IndexController=Ember.ArrayController.extend({ actions:{ createNew:function(){ //Access and Update a person record based on name } } }); How...

How can I do a “where in” type query using ember-data

ember.js,ember-data
How can I perform a where-in type query using ember-data? Say I have a list of tags - how can I use the store to query the API to get all relevant records where they have one of the tags present? Something like this: return this.store.find('tags', { name: { "in":...

Retrieving rendered json from ember .save() method

ember.js,ember-data
My rails backend renders a json response when I call .save() on my model. When doing a jquery ajax PUT request like this, I can retrieve the data returned (see below, data parameter) : $.ajax({ type : 'PUT', url: '/conversations/' + conversation.id + '/assignation', dataType: 'json', data: newAssignation, success: function(data)...

Get one item from many using slug in Ember.js

javascript,ember.js,ember-data
I have these two models: deomens.Artwork = DS.Model.extend({ title: DS.attr('string'), slug: DS.attr('string'), description: DS.attr('string'), thumbnail: DS.attr('string'), artwork: DS.attr('string'), created_at: DS.attr('string'), updated_at: DS.attr('string'), options: DS.hasMany('option', {async: true}), hasOptions: Ember.computed.gt('options.length',0) }); deomens.Option = DS.Model.extend({ name: DS.attr('string'), detail: DS.attr('string'), artwork: DS.belongsTo('artwork') }); I'm using the RESTAdapter like this: deomens.Store =...

Ember navigates to a show route, GETs the wrong URL (/tools instead of /tools/1)

ember.js,ember-data
I have a conventional Ember CLI app, and a conventional show route: export default Ember.Route.extend({ model: function(params) { return this.store.find('tool', params.tool_id); } }); But when I navigate to /tools/1, it GETs /tools instead of /tools/1! What am I doing wrong? Extra info... I'm using the --proxy http://127.0.0.1:3000 option to pass...

Emberjs get facebook friendlist

facebook-graph-api,ember.js,ember-data
I'm using Emberjs, Ember Simple Auth, and Torii (for the facebook-oauth2 provider). I was able to create a Facebook login and logout following this tutorial http://www.programwitherik.com/ember-simple-auth-torii-example-application/ For learning purposes, I'm trying to get my Facebook friendlist using the Ember Simple Auth and Tori not sure how to set up the...

How to access entity from relationship in ember-data?

ember.js,ember-data
I have two entities User and Token. I fetched token using store.find(..) and then I would like to get it's user but its undefined. // Route export default Ember.Route.extend({ needs:['session'], afterModel: function(token) { console.log(token); // defined, contains token console.log(token.get('user')); // undefined?? }, model: function (params) { return this.store.find('token', {token: params.token});...