ember.js

Testing: how to assert between two sequential promises/run.laters? How to skip `run.later` waiting in tests?

自作多情 提交于 2020-01-03 18:16:02
问题 Here's a simple component: App.FooBarComponent = Ember.Component.extend({ tagName: "button", status: "Ready", revertStatusPeriodMs: 2000, click: function() { this.set('status', 'Pending'); // A fake ajax this.run() .then( function() { this.updateStatus('Finished'); }.bind(this)) .catch( function() { this.updateStatus('Error'); }.bind(this)); }, run: function() { return new Ember.RSVP.Promise( function(resolve) { Ember.run.later( function() { resolve(); }, 500); }); }, updateStatus: function

Detecting keypress in Ember.js v2+

那年仲夏 提交于 2020-01-03 15:32:30
问题 I've problem with detecting keypress in ember v2.3.0. I'm beginer with ember and I try write simple component that display pressed key. But I got problem with run action and take parameters. Basicly I could use this.$().on("keypress",function(){ ... }); in didRender to get keyCode but I think it's not a good practice in Ember. Could someone help me with this? Please. :) Here is my code: http://emberjs.jsbin.com/vucenomibo/edit?html,js,output HTML: <script type="text/x-handlebars" data

Uncaught Error: Cannot call `compile` without the template compiler loaded. Please load `ember-template-compiler.js` prior to calling `compile`

随声附和 提交于 2020-01-03 14:15:32
问题 im new to the ember.js framework and using ruby on rails and ember.debug.js -v 1.10.1(latest release). I have been reading online that ember changed this latest patch but i cant figure out how to fix my problem of: Uncaught Error: Cannot call `compile` without the template compiler loaded. Please load `ember-template-compiler.js` prior to calling `compile`. Could someone please nudge me in the direction to getting my compiler to run properly? i wish i knew what code snippets from my project

EmberJS: The best way to reload controller's model based on another property?

风流意气都作罢 提交于 2020-01-03 08:06:30
问题 What is the best way to reload model for a current controller based on another property? For example: I have a post controller. Author can have only one post. I want to reload post creating form if currentAuthor property changes. I've tried that way: App.PostEditController = Ember.ObjectController.extend modelReloadNeeded: Ember.observer((obj, keyName) -> postId = @get('currentAuthor').get('post_id') if postId? @set('model', @store.find('post', postId)) , 'currentAuthor.post_id' ) It reloads

In Ember.js templates, how does one print out model's property that will be use by HTML like the src for image or href for link

余生颓废 提交于 2020-01-03 07:38:07
问题 Using: ember: v1.0.0-pre.4 ember-data: revision 11 handlebars: 1.0.rc2 So I have a template that I've hooked up to a controller that's receiving info from an REST API. In just print out text, this is fine but these handlebar expression... <img src="{{ imageUrl }}"/> ...when inserted into the dom look like: <img src="<script id='metamorph-28-start' type='text/x-placeholder'></script>http://asdf.com/image.jpg<script id='metamorph-28-end' type='text/x-placeholder'></script>"> I'm obviously very

Can't swap currentView of Ember.ContainerView in a #each

北战南征 提交于 2020-01-03 05:24:40
问题 I'm trying to use the the currentView feature of an Ember.ContainerView in the context of a #each helper but it fails when currentView property is changed to another view. My aim here is to allow editing an item of a list, by changing the regular view to an edit view when the user click a link. Main template: <ul> {{#each itemController="person"}} <li>{{view Ember.ContainerView currentViewBinding="cv"}}</li> {{/each}} </ul> Template 'name' used to display a person : {{firstName}} {{lastName}}

What's the right way of doing manual form data saving with Ember.js?

余生长醉 提交于 2020-01-03 03:58:49
问题 I'm trying to create a manually saved form with a moderate number of fields (let's say 20) in Ember.js (not using live bindings) and so far am confused about the correct way / best practice for doing so. I've found the following methods: http://www.solitr.com/blog/2012/06/ember-input-field-with-save-button/ How to use one-way binding on emberjs? https://stackoverflow.com/a/16473186/1248965 All of the above methods seem hacky to a degree; they either extend the text field or use a per-field

ember js with datatables plugin

倖福魔咒の 提交于 2020-01-03 03:37:06
问题 I am trying the datatable jquery plugin with EMber JS. Looks like the moment Ember tries to update the DOM with some fresh data, it has a problem after datatable has styled and inserted some elements like search bar, twitter bootstrap pagination footer etc. The code is as follows App.TableView = Em.View.extend({ classNames:['table','table-striped','table-bordered','dataTable'], tagName:'table', didInsertElement:function (){ this.$().dataTable({ "sPaginationType": "bootstrap", "oLanguage": {

Introduce momentary delays in ember-cli-mirage

纵饮孤独 提交于 2020-01-03 03:30:30
问题 I am using ember-cli-mirage for acceptance tests. For a specific case, I would like to check the behaviour while fetching data over a slow connection. There's a setting in ember-cli-mirage called timing that simulates a delay in the response. However, this setting cannot be changed to be different in a specific test: // app/mirage/config.js this.timing = 400; Something else I have tried is returning a promise at the fake endpoint. Through some import/export, I could control the resolution of

emberjs and ember-data -creating record via form submission returns undefined

 ̄綄美尐妖づ 提交于 2020-01-03 03:12:45
问题 I have this jsfiddle . Everything works excepting that i can't create a new comment by submitting the comment's form. when i submit a form the console shows undefined . What I hope to achive is to grab an existing post and then create a comment that belongs to that post. So this the flow of things, a user will click on post then click a specific post title to display it and then click on add comment to comment on that post. It is important to note that at the moment, clicking on add comment