ember.js

What is a promise object? [closed]

前提是你 提交于 2019-12-24 00:10:19
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . Having started learning Ember, I get confused whenever there is a reference to Promise Object. I am aware of objects e.g. instance of class X or a JSON object. For instance, when somebody says that method m returns a JSON object then I know to expect key-value pairs. How do I

Calling Handlebars {{render}} with a variable name

百般思念 提交于 2019-12-23 23:46:50
问题 Is there any way to pass a variable context to the {{render}} helper? For instance, I have a polymorphic relationship on my model, and I want to render the appropriate view for each different type (without have to write a whole string of if statements. my events template looks like this: <ul> {{#each event in model}} <li> {{event.time}} {{render event.type event.eventable}} </li> {{/each}} </ul> the event.type is a string and is set to song . If I use {{render 'song' event.eventable}}

Use query params of parent route to refresh the model in subroute

梦想的初衷 提交于 2019-12-23 23:13:28
问题 I have a route main which has a query param search . I have subroutes main.sub1 , main.sub2 Going to /main/sub1?search=hello or /main/sub2?search=hello sets the query param of the main route to hello . This part works fine. Now I would like to be able to refresh the model of main.sub1 when the query param search in route main changes, so I here is the code of the route main.sub1 : export default Ember.Route.extend({ queryParams: { search: { refreshModel: true } }, model(params) { // here I

Escape keyword in the handlebar template

血红的双手。 提交于 2019-12-23 23:12:39
问题 I have a collection of objects (MyApp.instrsController, an ArrayController) and each object has a property called 'action' (a float number), how can I display it using the handlebars template? Below is the code I've tried: <ul> {{#each MyApp.instrsController}} <li>{{action}}</li> {{/each}} </ul> But since 'action' is a 'keyword', it throws javascript runtime error 'options is undefined'. Thanks in advanced. 回答1: You can manually specify that you're looking for a property in the current

Ember.js: this._super in a callback function

时光怂恿深爱的人放手 提交于 2019-12-23 23:04:22
问题 I'm trying to figure out how to use this._super when the Ember's object method is called from a callback. I know that I could assign var _super = this._super before the callback is called but I don't like it. I want to have the this object containing proper _super method inside the callback. My code is here: http://emberjs.jsbin.com/hasehija/6/edit. App.BaseMixin = Ember.Mixin.create({ init: function() { console.log("base"); } }); App.Utils = Ember.Object.extend({ callbackMethod: function

EmberJS 2.7 - how to bind attribute 'disabled' for a button

徘徊边缘 提交于 2019-12-23 22:20:10
问题 This official guide describes how you can bind a boolean property to disabled attribute of a HTML element. Yet it talks about a controller. I have a button, that when clicked transitions the route (sorry it has to be a button and cannot be a link-to): /templates/trails.hbs <button type="button" class="btn btn-primary" disabled={{isEditing}} onclick={{route-action 'addNew'}}>Add New</button> (route-action is a helper that allows me to use closure actions in routes) /routes/trails.js import

How to catch whether array was inserted in handlebar in Ember?

℡╲_俬逩灬. 提交于 2019-12-23 21:28:01
问题 I hope this is not duplicate question, but I am not able to find solution... I have Jobs and Users, one user has many jobs: JP.User = DS.Model.extend({ firstName: DS.attr('string'), lastName: DS.attr('string'), email: DS.attr('string'), jobs: DS.hasMany("JP.Job") }); I am inserting data in user_dashboard.handlebar: {{#each job in jobs}} <li> {{job.shortDescription}}<br /> {{job.startsAt}}</li> {{/each}} This is my route: JP.DashboardRoute = Ember.Route.extend({ setupController: function

`SCRIPT` tags are not allowed in HTMLBars templates

无人久伴 提交于 2019-12-23 21:09:29
问题 Hi there and thank you for clicking my question. I have just upgraded my application to the latest ember-cli release ( 2.3.0-beta.1 ) and now one (or more) of my templates messed with the build. What coming next seems like a trivial issue, yet I never fully got around to it very well, so I'm finally asking. As the title suggests, I previously had <script> tags in my templates for minor things, such as a small jQuery conditional append() or anything doable by 2 or 3 lines of code. I never

How do I return the boolean value from this layer-cake of promises?

穿精又带淫゛_ 提交于 2019-12-23 20:57:14
问题 I've got a controller method that takes a string argument so I can test if a user has a capability. The user has many roles and the roles has an array of permissions attached that we need to check if it contains the capability. I know this is overly verbose, but for the sake of understanding, I've left it so. Will refactor later... App.WorkspaceIndexController = Ember.Controller.extend({ userCan: function(capability) { var userHasCapability = false; var userPromise = this.get('session.user');

Ember data rendering hasMany

ぃ、小莉子 提交于 2019-12-23 20:16:36
问题 In my ember app I have a models: App.Schedule = DS.Model.extend({ manager:DS.belongsTo('App.Manager', { embedded: true }), entries:DS.hasMany('App.Reservation', { embedded: true }) }); App.Reservation = DS.Model.extend({ name:DS.attr('string') }); and a handelbars view: {{#each schedule in controller}} <td> {{#each reservation in schedule.entries)}} <div>{{reservation.name}}</div> {{/each}} </td> {{/each}} But with this view a've got exception Expecting 'ID', got 'undefined' This workaround