ember-data

Ember.js child route conflicts with main application outlet

五迷三道 提交于 2019-12-11 14:04:02
问题 I’m trying to set up my template so it displays approved , disapproved and all photos, based off a boolean in my model. These routes all use the same main outlet in the application.hbs file (referenced below). These routes are working all fine, except when I go from photos → approved/disapproved → photos . In other words, when returning back to photos from either approved or disapproved , the outlet is blank (with no console errors). Refreshing the page brings it back again. Here’s how my

Can I use normal (rails default) JSON response on Ember Data?

杀马特。学长 韩版系。学妹 提交于 2019-12-11 13:58:36
问题 I'm working on a project using Ember / Ember-Data and there is a related/already existing service which is provide API with JSON response. My project must interact with that service, but the response from that API is someting like below: { "id": 39402, "name": "My Name" } or [ {"id": 38492, "name": "Other Name" } ] there is no person: or persons: that is required by Ember-Data compatable response. How can I using this response on Ember-Data without change on the service or without build API

Multiple serializers for a single model

﹥>﹥吖頭↗ 提交于 2019-12-11 13:36:35
问题 I have a User model that hasMany Reminders . When a User is first created, I want the reminders to be embedded. When it is updated, I don't want its reminders to be embedded. How can I do this? My strategy was to create a custom new-user-serializer that had DS.EmbeddedRecordsMixin and reminders: { embedded: 'always' } and use that in my UserAdapter s createRecord method, but I couldn't get it working. 回答1: It's not ideal, but you can do it - `import DS from 'ember-data'` `import

How are relationships saved in the popular Ember.js adapters?

家住魔仙堡 提交于 2019-12-11 13:23:10
问题 I think data relationships are saved in the adapters of the Ember app. So the way the REST adapter, the local storage adapter, and the fixture adapter saves relationships might be all different. Relationships might be saved in the parent or the child. I would like to know how each adapter saves relationships. Source code and examples would be appreciated. I'll update with my findings as well. 来源: https://stackoverflow.com/questions/17688671/how-are-relationships-saved-in-the-popular-ember-js

Ember-data: How do I set an incoming null value to an empty string value?

吃可爱长大的小学妹 提交于 2019-12-11 12:48:17
问题 I am using Ember-Data (v1.13.13) to manage objects coming from the server. The value of an incoming attribute is null. The attribute type is a string with default value being an empty string. The null is not defaulting to the empty string as expected. So it looks like Ember-Data establishes a nullable string data type by default (thinking about it in general terms, not a JavaScript thing, of course). In any case, I would like to know how to convert the incoming null to the default empty

Load data belonging to a parent model with Ember.js

笑着哭i 提交于 2019-12-11 12:43:28
问题 Considering something similar to the example outlined here: App.Router.map(function() { this.resource("posts", function() { this.resource("post", { path: "/posts/:post_id" }, function() { this.resource("comments", { path: "/comments" }); }); }); }); using the DS.RESTAdapter . The Router would load all the posts when I access the PostsRoute with a call to the API URL /posts . When I then access PostRoute , for example for the post with id=1 , it doesn't hit the API again, i.e. it doesn't hit

Empty content from promise?

。_饼干妹妹 提交于 2019-12-11 12:16:35
问题 I'm using ember-data , I call to my API using this.store.findAll('environment').then(function(values){ //1 },function(reason){ //rejected }); And my code does go into the //1, problem is I get this object which seems pretty invalid. Here is what my api sends back. { "data": { "environments": [ { "id": 1, "localePath": "C:\\XML_DEPOT", "name": "Acceptation 1", "remotePath": "D:\\XML_DEPOT", "databaseServerName": "blabla", "databaseName": "blabla", "port": 60903 }, { "id": 2, "localePath": "bob

Ember data Rest adapter error handling not working

陌路散爱 提交于 2019-12-11 11:57:08
问题 I have a basic Ember app and I am trying to handle validation errors on save (model is using the REST Adapter). In my route I am doing: task.save().then( function() {alert("success");}, function() {alert("fail");} ).catch( function() {alert("catch error");} ); When the record is valid I get the "success" alert, but when record is invalid, I do not get the "fail" alert OR "catch error". In the console I get: POST http://localhost:8080/api/tasks 422 (Unprocessable Entity) Error: The adapter

Emberjs- Running ember-data with fixtures returns DS.Store has no method 'create'

偶尔善良 提交于 2019-12-11 11:42:34
问题 This fiddle it returns the error shown below: **UnTypeError: Object <DS.Store:ember270> has no method 'create'** The code in the fiddle is pasted below : App = Ember.Application.create(); App.ApplicationController = Em.Controller.extend({ }); App.Store = DS.Store.create({ revision: 7, adapter: DS.FixtureAdapter.create() }); //models App.Account = DS.Model.extend({ name: DS.attr('string'), user: DS.hasMany('App.User'), project: DS.hasMany('App.Project') }); App.User = DS.Model.extend({ name:

Could not find property 'link_to' on object (generated application controller).

假装没事ソ 提交于 2019-12-11 11:38:39
问题 I have a simple index.html with an application template that includes: <script type="text/x-handlebars"> <nav> <ul> <li> <h1>{{#link_to 'index'}}Bookmarker{{/link_to}}</h1> </li> <li> {{#link_to 'bookmarks'}}Bookmarks{{/link_to}} </li> </ul> </nav> {{outlet}} </script> Otherwise my ember code is: App = Ember.Application.create(); App.Store = DS.LSAdapter; App.Router.map(function(){ this.resource('bookmarks'); }); when running this in the browser I get: DEBUG: -------------------------------