ember.js

Ensure the done() callback is being called in this test

自闭症网瘾萝莉.ら 提交于 2019-12-25 04:24:08
问题 it 'computes correctly when on & off have a list at cronRange[4]', -> @component.set('cronRanges', [Ember.Object.create({ on: "* * * 3 3,1,5" off: "* * * 3 3,1,5" })]) @component.set('dayOfWeek', 2) expect(@component.get('inRange')).to.be.false @component.set('dayOfWeek', 5) expect(@component.get('inRange')).to.be.true @component.set('dayOfWeek', 1) expect(@component.get('inRange')).to.be.true @component.set('dayOfWeek', 3) expect(@component.get('inRange')).to.be.true this is an ember unit

Ember SimpleAuth isAuthorised on itemController

ⅰ亾dé卋堺 提交于 2019-12-25 04:22:40
问题 In my app I need users to be given access to organisations according to a many-to-many relationship like this: App.User = DS.Model.extend({ fullname: DS.attr('string'), password: DS.attr('string'), administrator: DS.attr('boolean'), organisation_users: DS.hasMany('organisation_user', {async: true}) }); App.OrganisationUser = DS.Model.extend({ organisation: DS.belongsTo('organisation', {async: true}), user: DS.belongsTo('user', {async: true}), administrator: DS.attr('boolean') }); App

Getting a list of routes in Ember.js

假装没事ソ 提交于 2019-12-25 04:10:31
问题 On my main page ( index.hbs ), I need to display a list of links to each route which matches a given criteria, (e.g. has a certain attribute). So what I need is something like this: // Define a route with some attribute App.FirstRoute = Ember.Route.extend({ showOnIndex: true }); // Get a list of visible routes in the IndexController visibleRoutes: function() { var routes = /* How to do this */ return routes.filter(function(route) { route.get('showOnIndex')); }); }.property() The problem is

Mapping route to a explicit path does not work

江枫思渺然 提交于 2019-12-25 04:07:26
问题 I am defining a resource as explained here: App.Router.map(function () { this.resource('phones', { path: '/nodes/extensions/phones' }, function () { this.route('new'); }); But this is not working. Finding the phones performs a request to /phones instead of using the configured value /nodes/extensions/phones . What am I doing wrong? 回答1: The path here is the path used in the browser address bar, e.g. a user would access "http://yoursite.com/#/nodes/extensions/phones" to see this page on your

EmberJS - Checkboxes and Getting Values in Controller

a 夏天 提交于 2019-12-25 04:07:08
问题 Below is a simple example how I intend to use check boxes. What I have is an array of terms with id and name field and each post can be assigned to a single or multiple terms/categories. var config = {}; config.terms = [ {id: 1, termName: 'Red'}, {id: 2, termName: 'Green'}, {id: 3, termName: 'Blue'} ]; Problem With EmberJS handlebar expression I am showing those checkboxes but I am confused what to use as form element variable name field doesn't seem to defined in the controller. The checked

Binding on view with dependency

穿精又带淫゛_ 提交于 2019-12-25 03:58:19
问题 I am using a view to bind data to a contentEditable div using the code found in the answer to this question: Ember and HTML5 contenteditable property I have a property a.b.c that I'm binding it to like so: {{view App.ContenteditableView valueBinding="a.b.c"}} This correctly updates a.b.c when I type in it, and it updates itself when I modify a.b.c . However, It does not update when I change a to a different object. That is, the text box needs to update when a or b changes, not just when c

Can I use a pre-computed value as url parameter in emberjs

喜你入骨 提交于 2019-12-25 03:56:08
问题 I am just playing with angularjs and the ui-router module and I am not satisfied with it. I am missing a function/a process that allows me to execute logic before a state is activated. The logic is to calculate the first day of the week of the current logged in user. Thus before the weekly view of a calendar is activated I have to execute this date logic so the user gets an url like: /dateplanner/week/'firstdayOfWeek' Its not enough for me to show a /dateplanner/week url. 回答1: Yes. In

Ember.checkbox nested in action doesn't change value

好久不见. 提交于 2019-12-25 03:52:48
问题 Template: {{#each document in documents}} <div class="col-md-6" {{action "selectDocument" document}}>{{view Ember.Checkbox checked=document.isSelected}} {{document.name}}</div> {{/each}} Controller: App.IndexDocumentsController = Ember.ArrayController.extend({ actions: { selectDocument: function(document){ document.set('isSelected', !document.get('isSelected')); } } }); When I click on the div, the checkbox toggles 'checked' property. But when I click on the ckeckbox - nothing happens. What

How can I render dynamic HTML in component?

删除回忆录丶 提交于 2019-12-25 03:43:17
问题 I have the following Ember handlebar template and I want to render it to DOM dynamically including with the onclick event listener. How to do it in EmberJS? hello.js export default Ember.Component.extend({ didInsertElement() { var message = ` <p>Hello World!</p> <a onclick={{action "handleOpenUrl"}}>Learn More</a> `; this.set('message', message); }, actions: { handleOpenUrl() { //open url code } } }); hello.hbs {{{message}}} Expected output in DOM <p>Hello World!</p> <a>Learn More</a> And

Observe change on any attribute of an Ember Data

[亡魂溺海] 提交于 2019-12-25 03:34:07
问题 Is this possible? Something like .observes('_data') , but not. The use case is, I have a Decays mixin that has some CPs that say how long its been since a model has been updated. I'd like these CPs to be able to update if any of the model's attrs have changed. isDirty also won't work, since my use case uses store.push to update the model. 回答1: I don't think there's a built-in way to do it, but it wouldn't be very difficult to make one. Just create a base class for all of your models and