ember.js

What controls where Ember's Loading Route is displayed?

天涯浪子 提交于 2019-12-19 00:22:43
问题 I would have thought that the LoadingRoute would display its template in the {{outlet}} of the main AppView, but it doesn't seem like it does. What determines where it goes? Here's a JS Bin of my problem. The Loading message isn't showing up where I expect. 回答1: Suppose that you have this mapping: App.Router.map(function() { this.route("foo") }); When is transitioned to foo route. It template will be inserted in that was specified in the into property of render method. By example: App

How to get a reference on a view instance in ember / emberjs from static javascript?

不问归期 提交于 2019-12-18 21:20:45
问题 I have seen a lot of questions about that on the web (SOF and Google) but so far no clear answer to the issue. I have a usual Ember application with various views and controllers. One of my views has an instance method that I would like to call from a static context. Thus in a normal javascript file. I should I get a reference to the view instanciated by ember to call the method on ? A few lines of code to illustrate my issue : In ApplicationView.js : App.ApplicationView = Em.View.extend({

ember-cli --proxy works for GET but fails on PUT and POST

我只是一个虾纸丫 提交于 2019-12-18 20:08:10
问题 I'm trying to move my application from Ember Appkit to ember-cli and I'm having trouble replicating the proxy functionality previously provided by the APIMethod and proxyURL methods. I'm starting the server to proxy to localhost:3000 ember serve --proxy http://localhost:3000/ This will read my data from the rails server correctly. However, when I try to write to the server, I get an error message POST http://localhost:4200/api/v1/posts 408 (Request Time-out) It's trying to post to port 4200,

How do you access RESTAdapter's host and namespace inside a route or controller?

拈花ヽ惹草 提交于 2019-12-18 19:06:00
问题 I have a few custom AJAX requests that I use inside of some controllers and routes, for example: var loginRoute = Ember.Route.extend({ actions: { submitLogin: function(user, pass) { var data = { username: user, password: pass }; Ember.$.post('http://192.168.2.10/api/v1/login', data).then(); } } }); This works fine, but while developing I may have a different IP (e.g. changing routers) and I'd like to be able to access the URL(host + namespace) I defined when I extended the RESTAdapter so that

Recursive view in handlebars template not working after upgrading to Ember 0.9.6

半世苍凉 提交于 2019-12-18 17:29:26
问题 I used to be able to do something like this to get a nested unordered list of items: Javascript: App.Menu = Em.View.extend({ controller: App.menuController.create({}), tagName: 'ul', templateName: 'Menu', pageBinding: 'controller.page' }); Handlebars: <li> {{page.menuTitle}} {{#each page.childrenPages}} {{view App.Menu pageBinding="this"}} {{/each}} </li> index.html: <script type="text/x-handlebars"> {{view App.Menu}} </script> Now after updating to the latest Ember.js (0.9.6), only the last

How can I observe array changes and see which new element is added?

Deadly 提交于 2019-12-18 17:06:48
问题 onArrayChanged: function(obj, keyName, value) { // What is value here, exactly? }.property('array.@each') When an element is added to the array, how do I know which value was added? LIkewise, when a value is removed from the array, how do I access that? 回答1: Have a look at addArrayObserver, see http://jsfiddle.net/pangratz666/EE65Z/: var a = Ember.A('a b c d e f g'.w()); var o = Ember.Object.create({ arrayWillChange: Ember.K, arrayDidChange: function(array, start, removeCount, addCount) {

ember render hbs swallowing thrown error

守給你的承諾、 提交于 2019-12-18 16:55:28
问题 I have a simple component integration test: test('it throws error my-custom-input is called', function(assert) { assert.throws(() => { this.render(hbs`{{my-custom-input}}`); }, /my-custom-input component error/, 'Error must have been thrown'); }); Source code of component.js is like: export default Ember.Component.extend({ layout, init() { this._super(...arguments); throw 'my-custom-input component error'; } } While my ember-cli version was 2.3.0, the test was passing. However, after I've

Update view when pushing models to the store

爱⌒轻易说出口 提交于 2019-12-18 16:51:23
问题 I have quite a complex page in my application with lots of different models being shown. I live-update several of these models through a /updates REST call. I pass a last_request_timestamp parameter and it returns the models that were created or modified since the last call. I add the models to the store by using store.push(model, model_json) . However, the templates are not updated after the models have been pushed. How can I ensure that there is a binding between the models in the store and

Adding item to filtered result from ember-data

时光总嘲笑我的痴心妄想 提交于 2019-12-18 15:57:07
问题 I have a DS.Store which uses the DS.RESTAdapter and a ChatMessage object defined as such: App.ChatMessage = DS.Model.extend({ contents: DS.attr('string'), roomId: DS.attr('string') }); Note that a chat message exists in a room (not shown for simplicity), so in my chat messages controller (which extends Ember.ArrayController ) I only want to load messages for the room the user is currently in: loadMessages: function(){ var room_id = App.getPath("current_room.id"); this.set("content", App.store

Why is Ember.run afterRender not working for CSS transitions?

蓝咒 提交于 2019-12-18 15:42:30
问题 From my understanding, one way to work with CSS transitions is to use Ember.run.scheduleOnce('afterRender') However, for me it is not working without adding a timeout. This is in Ember 1.0.0 View = Em.View.extend({ didInsertElement: function() { Ember.run.scheduleOnce('afterRender', this, 'animateModalOpen'); }, animateModalOpen: function() { // this does not work - modal gets styles from class "in" with no transition $('.modal').addClass('in'); // this does work, the transition is fired