ember.js

Emberjs - How to access the current state or route name in RC1?

有些话、适合烂在心里 提交于 2020-01-02 03:56:26
问题 In RC1 how can I get the currentstatename or current route name globally? More specific, alternate syntax of : App.get('router').currentState.name; 回答1: Have a look at the answer to this question: Ember App.Router.router.currentState undefined Short answer: The current state is stores in the ApplicationController under the name "currentPath". 来源: https://stackoverflow.com/questions/15318981/emberjs-how-to-access-the-current-state-or-route-name-in-rc1

Observing a property on a service from a route in EmberJS

家住魔仙堡 提交于 2020-01-02 03:24:08
问题 I think I'm not understanding a concept here. As far as I know any Ember.object can observe properties on another Ember.object . So, I have a service, a router, and a component. I need the component and the router to be able to observe a property on the service. It's entirely possible that I'm just structuring the solution in the wrong way, I'll include an overview of what I'm trying to do at the end. Here is approximately what I have: /services/thing-manager.js export default Ember.Service

Pass a reference of the clicked DOM element to the action handler in Ember

随声附和 提交于 2020-01-02 01:20:26
问题 I have a set of buttons whose state I wish to toggle with a class active . If I had a single button, then I would bind the active class to a controller property and toggle that property in the click handler: <button {{action 'toggle'}} class="{{active}}">model.title</button> actions: { toggle: function() { this.set('active', true); } } But I have multiple buttons, so I am not sure what I can bind. It would be useful if I could pass a reference to the clicked button to the action handler, but

Instance initializer unit test fails with “store is undefined”

瘦欲@ 提交于 2020-01-02 01:04:12
问题 After generating an example application: ember new preloadtest cd preloadtest/ ember g instance-initializer preload ember g model test-data ember g route index ember g adapter application With the following files: models/test-data.js import DS from 'ember-data'; export default DS.Model.extend({ name: DS.attr('string'), value: DS.attr( 'number' ) }); routes/index.js import Ember from 'ember'; export default Ember.Route.extend({ model(){ return this.store.peekAll( 'test-data' ); } }); instance

Ember.js order hasMany children

限于喜欢 提交于 2020-01-01 19:36:12
问题 I have a item model and each item can have many items. This can be many levels deep. I have this jsfiddle http://jsfiddle.net/rmossuk/xmcBf/3/ how do I change this to be able to have multiple levels of items and also how do I loop down each level to display them ? I also need be able to order each items children and store that order to persist to server. please can anyone show me how you can do this ? UPDATE: I have now managed to implement the Items can be many levels deep bit of this

Ember.js - Prevent re-render when switching route

梦想与她 提交于 2020-01-01 19:19:07
问题 Simplified demo: http://jsfiddle.net/indream/KskXx/ (this demo cannot simulate actual environment with my problem) For the demo: Hover on photos will show you the caption. When you clicked a photo, route changed to 'media' with {{linkTo}} helper & lightbox opened. When clicked place outside lightbox, route changed back to 'feed' by history API & lightbox closed. My question : Template re-rendered when switch back to 'feed'. (You can check it by hover on photos as caption lost after that.) I

EmberJS and WebSocket | Best Approach?

只谈情不闲聊 提交于 2020-01-01 18:56:13
问题 I have a again which I can't answer for my self properly, maybe because of my lack in expierience with EmberJS. I have to develop a management interface in EmberJS, using Symfony 2 for the backend, which should act and feel like a desktop application. So far so good, but since alot of people will work with the data inside this application, i would really like to use a WebSocket adapter implementation for EmberJS, since every connected client should always know about changes in entities

how to deploy ember-cli project in apache server

混江龙づ霸主 提交于 2020-01-01 18:55:16
问题 I have the following problem. I created an ember application with ember-cli. The application works fine on nodejs through the url http://localhost:4200/ when running the command ember serve I want to deploy this application on an apache httpd server. In order that this will work i think that it should work also standalone when opening in firefox. When i open it in firefox i get an error: require is not defined The generated index.html is <!DOCTYPE html> <html> <head> <meta charset="utf-8">

How can I make custom events that bubble through the view hierarchy?

孤街浪徒 提交于 2020-01-01 12:49:26
问题 I have button views that are part of a set of Ember.js form helpers I wrote. E.g. MyAddressFormView has the following template: {{#form}} {{textArea address}} {{submitButton}} {{cancelButton}} {{/form}} To handle the "Submit" button, I let the "submit" form event bubble, and handle it in the submit method of MyAddressFormView. But how do I do the same for the "Cancel" button? For instance, is there any way I can trigger a custom "cancel form" event in a child view, let it bubble, and handle

Ember fewer requests for hasMany and belongsTo lookups

空扰寡人 提交于 2020-01-01 12:20:14
问题 I have the following three models: ConversationApp.Post = DS.Model.extend( body: DS.attr() replies: DS.hasMany('reply', async: true) author: DS.belongsTo('user', async: true) likedBy: DS.hasMany('user', async: true) ) ConversationApp.Reply = DS.Model.extend( body: DS.attr() post: DS.belongsTo('post') author: DS.belongsTo('user', async: true) likedBy: DS.hasMany('user', async: true) ) ConversationApp.User = DS.Model.extend( firstName: DS.attr() lastName: DS.attr() ) And my index route makes