ember.js

EmberJS: How to update model attributes

梦想的初衷 提交于 2020-01-05 10:15:09
问题 I've got a list of messages that are provided by a Rails backend. What I need is when the "toggle_visibility" action button is pressed, it would toggle the "publicly_viewable" property. This means, making a corresponding REST call (to effect the database) and changing the state of the corresponding cached message. Here is where I'm at so far. Here's what I've got so far, that manages to end up on the debug console: # app.js App.Store = DS.Store.extend({ revision: 12, adapter: DS.RESTAdapter

EmberJS: How to update model attributes

浪尽此生 提交于 2020-01-05 10:15:01
问题 I've got a list of messages that are provided by a Rails backend. What I need is when the "toggle_visibility" action button is pressed, it would toggle the "publicly_viewable" property. This means, making a corresponding REST call (to effect the database) and changing the state of the corresponding cached message. Here is where I'm at so far. Here's what I've got so far, that manages to end up on the debug console: # app.js App.Store = DS.Store.extend({ revision: 12, adapter: DS.RESTAdapter

Where did my data get stuck in Ember? <!---->

大城市里の小女人 提交于 2020-01-05 10:08:21
问题 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 my app. Is there a general way how to debug when you just get <!----> in your ember app? mirage/fixtures/contacts.js export default [ { id: 1, userName: "Barack Obama", profilePictureUrl: "/img/profilepics/barack.png",

Nested routes in Ember

泄露秘密 提交于 2020-01-05 09:35:19
问题 I want my settings area to look like this: .. /settings/:accountId/users /settings/:accountId/users/:userId I have my router defined as follows: Router.map(function() { this.route('login'); this.resource('settings', { path: 'settings/:settings_id' }, function() { this.route('overview'); this.route('users'); }); }); This works for displaying the users listing page. I'm not sure how to take it to the next step though and have both a route and a resource for /users and /users/1 . Thanks. 回答1: In

Ember Assertion Failed: The response from a findQuery must be an Array, not undefined

三世轮回 提交于 2020-01-05 09:29:32
问题 As the title says, the error I am getting is: Error while processing route: index Assertion Failed: The response from a findQuery must be an Array, not undefined I checked every single SO answer (like this one or this one) I could find with similar error like mine and none of the solutions provided helped me solve my problem. I am learning Ember and trying to mess around with Ember Data RESTAdapter and RESTSerializer to fix up the JSON response from OMDB API. Most answers to the error I am

Delay tests till Ember.run.later is done

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-05 09:29:09
问题 I am trying to get some tests to pass for an ember addon. It was working fine until yesterday I added some code that runs later in the run loops using Em.run.next. Here is what Im doing in my test. visit('/').then(function() { find('bm-select').click(); andThen(function() { equal(1,1, 'yay'); }); }); The problem is when click is triggered, the later function is executed after andThen . By that time all my tests are done and it throws error. I am under the impression andThen should wait for

Simulate a ember-select2 selection in ember integration test

喜夏-厌秋 提交于 2020-01-05 08:32:25
问题 Has anyone been able to simulate a select2 selection of an option? So far I've tried this: test("Checking navigation", function () { expect(1); visit("/hub"); click("#btnLogin"); andThen(function () { click(".select2-container"); andThen(function () { }); }); }); But I have not seen changes in the UI. 回答1: We need to hit the anchor inside the container Ember.$(" .select2-container a").trigger({type:'mousedown', which:1}); If you want to select an item in the dropdown you can do: Ember.$("

Embedded objects in fixtures raise “unable to find fixtures” errors

情到浓时终转凉″ 提交于 2020-01-05 08:31:21
问题 I'm using ember-data's fixtures adapter extensively to provide a lot of set-up data in my app. For one model ("Structure"), there is an array of embedded related objects ("Overlays"). When I load a Structure instance from the store, then query its overlays property, I get this error: Uncaught Error: assertion failed: Unable to find fixtures for model type App.Overlay Both models are defined as follows (with a few other fields/relationships removed for clarity): App.Structure = DS.Model.extend

Embedded objects in fixtures raise “unable to find fixtures” errors

99封情书 提交于 2020-01-05 08:29:21
问题 I'm using ember-data's fixtures adapter extensively to provide a lot of set-up data in my app. For one model ("Structure"), there is an array of embedded related objects ("Overlays"). When I load a Structure instance from the store, then query its overlays property, I get this error: Uncaught Error: assertion failed: Unable to find fixtures for model type App.Overlay Both models are defined as follows (with a few other fields/relationships removed for clarity): App.Structure = DS.Model.extend

EmberJS - didInsertElement for previously displayed view

冷暖自知 提交于 2020-01-05 08:15:15
问题 I have a flow with multiple pages and when I use 'transitionTo' to go back to a route/view that has already been displayed, it's 'didInsertElement' method is not called. (it was fired the first time the view was displayed, though) Is there an event that my view can hook into that will be called every time it is displayed? My routes look something like this App.Router.map(function() { this.resource("parent", { path: "/parent" }, function() { this.resource("child", { path: "/child" }); }); });