ember.js

Model reloading with Ember Data

南笙酒味 提交于 2019-12-22 04:33:10
问题 I'm trying to poll for more data using the documented model.reload() function App.ModelViewRoute = Ember.Route.extend({ actions: { reload: function() { this.get('model').reload(); } } }); But i'm getting an error message saying... undefined is not a function TypeError: undefined is not a function Is there a better way of doing this, it seems like I cannot access the model in this way from the route? Here is the router App.Router.map(function() { this.route('video', { path: '/videos/:video_id'

How do I set an “ENV” variable in EmberJS?

懵懂的女人 提交于 2019-12-22 04:25:11
问题 After updating to EmberJS 0.9.8.1 I now get two warnings: WARNING: Computed properties will soon be cacheable by default. To enable this in your app, set `ENV.CP_DEFAULT_CACHEABLE = true`. And: WARNING: The way that the {{view}} helper affects templates is about to change. ...SNIP... by setting `ENV.VIEW_PRESERVES_CONTEXT = true`. This may seem like a stupid question, but how do I set these ENV variables? I've tried setting them a few different ways, and none make the WARNING message go away,

How do I set an “ENV” variable in EmberJS?

别等时光非礼了梦想. 提交于 2019-12-22 04:25:04
问题 After updating to EmberJS 0.9.8.1 I now get two warnings: WARNING: Computed properties will soon be cacheable by default. To enable this in your app, set `ENV.CP_DEFAULT_CACHEABLE = true`. And: WARNING: The way that the {{view}} helper affects templates is about to change. ...SNIP... by setting `ENV.VIEW_PRESERVES_CONTEXT = true`. This may seem like a stupid question, but how do I set these ENV variables? I've tried setting them a few different ways, and none make the WARNING message go away,

How to use autofocus with ember.js templates?

廉价感情. 提交于 2019-12-22 04:10:10
问题 I have a simple ember.js text field and I'm trying to add autofocus {{view PersonApp.SearchField placeholder="search..." valueBinding="searchText"}} PersonApp.SearchField = Ember.TextField.extend({ }); Can I add this in the javascript or is at as simple as a attribute in the template itself? 回答1: Update: More recent versions of Ember now have support for this built in, so you no longer need to reopen TextField to add an attributeBinding. As of January 2014 (commit fdfe8495), you can simply

Ember.js Data how to clear datastore

风流意气都作罢 提交于 2019-12-22 04:09:49
问题 I am experiementing with Ember.js and have setup a small app where users can login and logout. When the user logs out I want to clear all of the currently cached records in the Data Store. Is there a way to do this or would I have to force the browser to reload the page? 回答1: Clearing the data store is not yet supported in Ember-Data. There is an open issue concerning this on the Github tracker. 回答2: I know this question is from 2013. But since Ember Data 1.0.0-beta.17 (May 10, 2015) there's

Ember-CLI: Is there a way to copy a (vendor) directory to /public/assets?

旧时模样 提交于 2019-12-22 04:09:11
问题 In an Ember-CLI project, if I add a directory containing webfonts and their CSS stylesheets to the public/assets directory, I can use them with something like @import 'assets/font/regular/stylesheet.css . This works fine. Ideally though, I'd like to keep these assets out my git repository, and instead bower install them as client-side dependencies, but how can these assets be used in the Ember-CLI build? The documentation mentions app.import(FILE) in Brocfile.js , which works for CSS

Inserting a Model Property into an Img Element URL in Ember

守給你的承諾、 提交于 2019-12-22 04:05:55
问题 I have a Model with an image_id property. I have a View for that Model that contains an image element. I need to insert the id into the image element's src property to complete the URL of the image so that I'm effectively doing this: <img src="news + newsItem.imageID + .jpg"></img> My first attempt used a Handlebars helper: <img src="news{{newsImageURL newsItem.imageID}}.jpg"></img> But this also inserted Metamprph script tags around it: <img url="<script id='metamorph-10-start' type='text/x

How to test String.prototype.includes in PhantomJS

大城市里の小女人 提交于 2019-12-22 04:05:30
问题 I have an ember-cli 0.2.7 using Ember.js 1.12.0 app with a piece of code that looks like: controllers/cart.js import Ember from 'ember'; export default Ember.Controller.extend({ footwearInCart: Ember.computed('model.@each.category', function() { return this.get('model').any(product => product.get('category').includes('Footwear')); }) }); It goes through all the objects in the model and returns true if their category property has 'footwear' in it. I'm trying to test it like so: tests/unit

Ember deeply nested routes do not keep parent dynamic parameter

吃可爱长大的小学妹 提交于 2019-12-22 04:03:59
问题 I've got this ember application: Ember : 1.3.2 Ember Model : 0.0.11 Handlebars : 1.3.0 jQuery : 1.9.1 Using this resource map: App.Router.map(function () { this.resource('dimensions', function() { this.resource('dimension', { path: ':dimension_id'}, function () { this.resource('value', { path: 'values/:value_id' }); }); }); }); And this allows me to embed {{outlet}} in "dimensions" template that fills with "dimension" template, and embed {{outlet}} in "dimension" template that fills with

Ember Component Integration Tests: `link-to` href empty

大憨熊 提交于 2019-12-22 03:48:51
问题 I'm trying to write a component integration test, a la this blog post, but my component has a link-to to a dynamic route and the href property isn't being filled in. Here is a simplified version of what I'm trying to do. My component's template: {{#link-to "myModel" model}} And here is the relevant part of my test: this.set('model', { id: 'myId', name: 'My Name' }); this.render(hbs` {{my-component model=model}} `); assert.equal(this.$('a').attr('href'), '/myModel/myId'); // fails The link-to