ember.js

Getting the model inside a controller emberjs

大憨熊 提交于 2019-12-24 15:12:50
问题 I need to get the grand total price of all the objects returned from a JSON API. my idea is to create a controller and set a property on it. Then grab the model loop over each object and add to the predefined property that objects total price. Something like this: export default Ember.Controller.extend({ orderTotal: 0, getOrderTotal: function(){ var model = this.get('model'); model.forEach(function(c){ var order_total = this.get('orderTotal') * c.total_price; this.set('orderTotal', order

Rerender view after change route's dynamic segment

落爺英雄遲暮 提交于 2019-12-24 15:12:29
问题 I have a Route with dynamic segment :id. When I change only the dynamic segement part manually in browser url input field, then goes a transition, and all model hooks are called as expected. The problem is: none of the views are rerendered. I guess it is because only model changed - not the UI. But I have some UI logic in views' didInsertElement handler - reinitialize UI plugins and so on. How to force ember to rerender view after dynamic segment change? 回答1: I agree with the josh's comment.

Ember Data Multiple Stores

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 14:50:10
问题 So I'm just starting to learn ember js. In the case of the application rest api I have namespaced models. example: App.GlAccount = DS.Model.extend({}) the route I need it to follow is /gl/account I thought I could fix this by creating another store like App.GlStore = DS.Store.create({adapter:DS.RestAdapter({namespace:'gl'})} The problem is the model uses App.Store...Anyway to tell a model to use a different store? 回答1: Based on your example it doesn't sounds like you actually need to have

Automatically generating IDs with Ember & Firebase

浪子不回头ぞ 提交于 2019-12-24 14:13:08
问题 I'm trying to generate ID's for a model. Ember documentation says that Ember automatically generates IDs for its models. But when I pass data to Firebase and try to display it, the IDs return undefined. Is there something wrong with my code? <script type="text/x-handlebars" id="stack"> <div class='stack'> <div class="container"> <div class="row"> <div class="span12" style="text-align:center; margin: 0 auto;"> {{#if isEditing}} {{partial 'stack/edit'}} <button {{action 'doneEditing'}}>Done<

How to dynamic update 2 templates simultaneously in emberjs

吃可爱长大的小学妹 提交于 2019-12-24 14:03:09
问题 in the folowing jsFiddle i have add a little example ember application. In the 'details' view i want to display information about the selected group and if i click on a device in a group, i want to replace the details with the device details. How can i manage this in ember way? http://jsfiddle.net/theremin/qGCe6/1/ TEMPLATES <script type="text/x-handlebars" data-template-name="application"> <h2>SampleApp</h2> {{outlet}} </script> <script type="text/x-handlebars" data-template-name="groups">

Dynamically setting select key in Ember within select field

浪尽此生 提交于 2019-12-24 14:00:24
问题 So I have an API that generates forms from a database. The API for the fields returns: { "formFields": [ { "module": 1, "fieldName": "Global Title", "fieldPosition": "1", "fieldType": "select", "fieldEditable": true, "dataTable": "message", "dataKey": "calling_gt", "dataValue": "id", "id": 1, "createdAt": "2015-10-15T13:59:30.764Z", "updatedAt": "2015-10-15T13:59:30.764Z" } ] } I have multiple Ember components. Essentially an Add Parameter component that loops through the fields related to

EmberJS: Refreshing a model?

纵饮孤独 提交于 2019-12-24 13:35:04
问题 Hello again everyone. EDIT: I want to emphasize that I can find no docs on the solution for this. I am using a route to perform a search query to my server. The server does all the data logic and such and returns a list of objects that match the keywords given. I am taking those results and feeding them to the model so that I can use the {{#each}} helper to iterate over each result. The problem I am having is that the model does not want to refresh when the searchText (search input) changes.

Context binding while using nested each blocks in Ember Handlebars

大兔子大兔子 提交于 2019-12-24 13:33:49
问题 I just stumbled over emberJS and thought it would be worth trying it out for my next web application. What I actually plan to do is showing a list of objects in a 2-dimensional way (atm this can be a table). What I have so far: <script type="text/x-handlebars"> <table width="100%" style="text-align:left"> <tr> <th> </th> {{#each App.MyController.getColumnValues}} <th>{{this}}</th> {{/each}} </tr> {{#each App.MyController.getRowValues}} <tr> <th>{{this}}</th> {{#each App.MyController

Ember integration testing hangs after visiting route

◇◆丶佛笑我妖孽 提交于 2019-12-24 13:32:56
问题 I am trying to do a simple integration test and I started from the integration example on the ember-cli website. Right now when I test in a browser (localhost:4200/tests), the follow case routes to where I expect, but then it just hangs and never does success or failure. import Ember from "ember"; import { test } from 'ember-qunit'; import startApp from '../helpers/start-app'; var App; module('Integration - Create Event', { setup: function() { App = startApp(); }, teardown: function() { Ember

Force to refresh ember view

让人想犯罪 __ 提交于 2019-12-24 13:32:55
问题 i have an ember view with a bunch of jquery code to manipulate the dom, the thing is when i use: this.transitionTo("forecast.workpage", id); it only loads the view once but when i try click it again the view doesn't execute again, i try several ways for instance adding this.rerender() in the end of my didInsertElement like that: didInsertElement : function(){ //all my js code this.rerender() } but it trows an error Uncaught TypeError: Cannot read property '0' of undefined , try adding this.