ember.js

application route's model hook not triggering in qunit integration test

南楼画角 提交于 2019-12-25 06:58:16
问题 I have a route that looks like this: App.ApplicationRoute = Ember.Route.extend({ model: function() { console.log("caching books"); this.store.find('books'); } }); When I run it locally I see the "caching books" message in the console. But when I run it in qunit the message never shows up. Why does the application route's model hook not fire in qunit? Here's my qunit integration test: module('Ember.js Library', { setup: function() { Ember.run(App, App.advanceReadiness); }, teardown: function()

Accessing other controller from a view

a 夏天 提交于 2019-12-25 06:35:38
问题 i try to set a property of another controller via my click function. click: function(event){ var controller = this.get('controller'); router.transitionTo('inc.index',this.content); console.log(controller.hidden) controller.set('hidden',false); } }) Therefore i set up my tableController with a hiddenbinding: App.TableController = Em.ArrayController.extend({ needs: ['mainMenu'], hidden:true, hiddenBinding: 'controllers.mainMenu.isHidden' }) App.MainMenuController= Em.Controller.extend({

Embli-Cli Not work after Building

喜你入骨 提交于 2019-12-25 06:13:43
问题 Iam working around Ember-Cli.I build a project and customize the "ember-cli-build.js" but finally it doesn't work. this is my work steps: 1) ember new myapp cd myapp ember server it works fine and i can see my project on "http://localhost:4200" 2) then run ember build --environment=production and get Built project successfully. Stored in "dist/". so it appear that my project built. 3) then i run this url on browser that direct to my dist directory project localhost/~/myapp/dist/index.html but

Delete Record in Emberjs

偶尔善良 提交于 2019-12-25 06:07:09
问题 I am struggling to follow ember 2.0's documentation for deleting records and then redirecting to a new url. When I try, I get the following error to the console: Error while processing route: pencils Attempted to handle event `pushedData` on <name-emberjs@model:pencil::ember523:null> while in state root.deleted.inFlight. Error: Attempted to handle event `pushedData` on <name-emberjs@model:pencil::ember523:null> while in state root.deleted.inFlight. My files follow. Routes: import Ember from

Ember pre-render: timed out while initializing

狂风中的少年 提交于 2019-12-25 06:01:41
问题 I am trying to create a pre-render server for my ember app. I installed ember-prerender (https://github.com/zipfworks/ember-prerender), used the initializers provided in the /example, deployed it on one of my servers. But when I try to launch it: Restarting renderer, timed out while initializing This is the case even if I change engine (I tried with Phantom and jsdom). My best guess is that the XContentReady event is never fired. 回答1: So it was indeed XContentReady not firering that was

Ember.computed.sort doesn't seem to work

十年热恋 提交于 2019-12-25 05:30:37
问题 I have a template like so: {{#each rate in package.ratesSorted}} {{rate.year}} {{/each}} I want the rates to be sorted by ascending year, so I have: var Package = DS.Model.extend({ rates: DS.hasMany('rate'), ratesSorted: Ember.computed.sort('rates', (a, b) => { return a.get('year') > b.get('year'); }) }); Package.reopenClass({ FIXTURES: [ {id: 1, rates: [1, 3, 4]} ] }); And my rate Model looks like this: var Rate = DS.Model.extend({ year: DS.attr('number'), }); Rate.reopenClass({ FIXTURES: [

emberjs router @pangratz example class active

北慕城南 提交于 2019-12-25 05:11:18
问题 @pangratz give a answer in emberjs - how to mark active menu item using router infrastructure The question is why when i change {{outlet "navigation"}} to {{view App.NavigationView}} , NavigationView.selected is undefined? 回答1: I think using {{view App.NavigationView controllerBinding="App.router.navigationController"}} should make your code working. Thanks to this question: connectOutlets from root state called before initialization? 来源: https://stackoverflow.com/questions/11767161/emberjs

Ember, hasMany and belongsTo doesn't work

我的未来我决定 提交于 2019-12-25 05:05:23
问题 I tried a simple emberapp to display some userdata. My API returns me this json: { "roles":[ { "id":5, "name":"admin", "alias":"Administrator", "users":[ { "id":1, "username":"Evolutio", "email":"mail@evolutio.tld", "display_role":"Administrator" } ] }, { "id":2, "name":"user", "alias":"Benutzer", "users":[ ] }, { "id":1, "name":"banned", "alias":"Gesperrt", "users":[ ] }, { "id":3, "name":"mod", "alias":"Moderator", "users":[ ] }, { "id":4, "name":"support", "alias":"Supporter", "users":[ ]

edit template not displaying on edit route

这一生的挚爱 提交于 2019-12-25 04:55:09
问题 I would like to edit users. I am following this tutorial: http://coding.smashingmagazine.com/2013/11/07/an-in-depth-introduction-to-ember-js/ I have a button in user.hbs to edit the user: <button {{action "edit"}}>Edit</button> and below it is an {{outlet}} When click it I'm directed to /index.html#/users/4/edit but my user.edit.hbs template does not show up Here's userEditRoute.js : App.UserEditRoute = Ember.Route.extend({ model: function(){ return this.modelFor('user'); } }); And the

Ember 2.7, Rails 5, JSONAPI, Active Model Serializers - counting the number of records in a hasMany relationship

感情迁移 提交于 2019-12-25 04:48:12
问题 This idea started with this question. 2 models: class Trail < ApplicationRecord has_many :notes, dependent: :destroy end class Note < ApplicationRecord belongs_to :trail end 2 serializers: class NotesSerializer < ActiveModel::Serializer attributes :id, :note_body belongs_to :trail end class TrailSerializer < ActiveModel::Serializer attributes :id, :name, :notes_count has_many :notes def notes_count object.notes.size end end When calling the route trails/index, this will fire for every Trail,