ember.js

How do I change query parameters in Ember?

浪尽此生 提交于 2019-12-12 20:05:51
问题 I'm writing an action handler in route:application : actions: { changeFoo(foo) { // I want to change the fooId queryParam to foo.get('id') } } The problem is that the only documented ways I can find to change the query params are transitionTo('some.route', someModel, { queryParams: { ... } } and the replaceWith version of the same. But I'm in route:application , so I don't know the current route's name. That means I don't know what the first argument to transitionTo would be. Is there another

Add “active” class to bootstrap dropdown menu when dropdown link selected (with Ember link-to)

女生的网名这么多〃 提交于 2019-12-12 19:54:05
问题 I'm using Twitter Bootstrap and have a navbar with a regular link and a dropdown link. Using ember's link-to helper, the regular link automatically gets the "active" class when clicked, as do the menu items in the dropdown menu. However, I cannot for the life of me figure out what the best way to get the parent li tag to get the "active" class when one of the dropdown menu items is selected. I've tried creating a component out of the dropdown menu but I cannot get it to work. Markup in

How to load multiple models sequentially in Ember JS route

时间秒杀一切 提交于 2019-12-12 19:53:08
问题 What is the best way to load multiple models sequentially in Ember JS? e.g. App.ProductRoute = Ember.Route.extend({ model: function(params) { // first call this.store.find('Product'); // second call should only be called after the first find is completed var prod = this.store.find('Product', params.product_id); // third call should only be called after the above is completed this.store.find('ProductOptions', prod.get('optionId'); return ??? }, setupController: function(controller, model){ //

Ember Engines inside Rails Engines via ember-cli-rails

别说谁变了你拦得住时间么 提交于 2019-12-12 19:50:54
问题 We have a high modular rails5 app, which is splitted in rails engines over serveral repositories and integrated as ruby gems. Now we want to introduce EmberJS by using ember-cli-rails . The main rails application contains the main ember application in the frontend directory while each of the rails engines contain an ember engine (via ember-engine ) in a frontend directory. How to mount the ember engines of the modules into the main ember engine? 回答1: Due the fact that I've found no other

Could not start watchman; falling back to NodeWatcher for file system events

此生再无相见时 提交于 2019-12-12 19:40:20
问题 I get the below error message while I switch between my ember applications: version: 2.4.2 Could not start watchman; falling back to NodeWatcher for file system events. Visit ember-cli.com for more info. Livereload server on http://localhost:49153 Could not serve on http://localhost:4200. It is either in use or you do not have permission. Here are the packages that I have setup on my machine: npm --version 2.14.20 bower --version 1.7.7 ember --version 2.4.2 node: 4.4.0 os: linux x64 回答1:

Cleaner way to remove events attached to window scope once the view is destroyed

人盡茶涼 提交于 2019-12-12 19:01:13
问题 So I have a view that implements fixed header by watching scroll event on the window. didInsertElement: function () { var self = this; $(window).on("scroll resize", function () { if (self.onWindowScroll) { Ember.run.throttle(self, 'onWindowScroll', 150); } }); }, onWindowScroll: function () { //do stuff }, willDestroyElement: function () { this.set('onWindowScroll', null); } This works but I was wondering if there is a cleaner approach for removing the logic attached to the scroll event.

Emberjs route with args fail in some case

不打扰是莪最后的温柔 提交于 2019-12-12 18:52:29
问题 In some case I got an issue with the routing url. Here's my router : contacts: Em.Route.extend({ route: '/contacts', index: Em.Route.extend({ route: '/', connectOutlets: function(router, context) { App.contactsController.populate() var appController = router.get('applicationController'); appController.connectOutlet('contactsList'); } }), show: Em.Route.extend({ route: '/:contactid', connectOutlets: function(router, context) { alert('show contact'); } }), doShowContact: function(router, event)

Use Onload on image tag in ember

徘徊边缘 提交于 2019-12-12 18:22:31
问题 I have a template in which photos are being displayed in a frame ( each frame is different for different images) .I have written a function which uses the images original height and width and gives me customized width and height for that particular frame inorder to restore the aspect ratio.Now I have called that function through onload as images loads on that particular moment. My feed.hbs( template) <img src = "{{photo.0.photo_url}}" onload = "OnImageLoad(event);" {{action "imgOverlay0"

Force a controller to always act as a proxy to a model in Ember

给你一囗甜甜゛ 提交于 2019-12-12 18:15:33
问题 I'm looping through a content of an ArrayController whose content is set to a RecordArray. Each record is DS.Model, say Client {{# each item in controller}} {{item.balance}} {{/each}} balance is a property of the Client model and a call to item.balance will fetch the property from the model directly. I want to apply some formatting to balance to display in a money format. The easy way to do this is to add a computed property, balanceMoney, to the Client object and do the formatting there: App

How do I save data to my Ember store if the POST response contains only an id?

时光总嘲笑我的痴心妄想 提交于 2019-12-12 17:26:23
问题 Ember data expects my server to return the full object after each successful POST . However, my API only returns a kind of meta-object that contains the id . When Ember receives this object, the existing data in the record gets deleted except for the id . So for example, when I do this: var asset = App.Asset.store.createRecord('asset',{name: 'foo.ai', paths: ['/path/foo.ai', '/another/path/foo.ai'], type: 'ai', hash: '1234567890123456789012345678901234567890', datecreated: 'Sun, 12 Jan 2014