ember.js

filter paginate pass parameters to asynchronous ember data relationship requests

泪湿孤枕 提交于 2019-12-22 08:55:48
问题 I want to implement paging/filtering on ember data asynchronously. This is my author model: export default DS.Model.extend({ user: DS.belongsTo('user'), articles: DS.hasMany('article', { async: true }), name: DS.attr('string'), email: DS.attr('string') }); route: export default Ember.Route.extend({ model: function(params) { return this.store.find('author', params.author_id); } }); controller: export default Ember.ObjectController.extend({ popularArticles: function() { return this.get('model

Initialized dependency not present when testing

旧巷老猫 提交于 2019-12-22 08:46:27
问题 I'm using ember-cli 0.0.35, and injecting a dependency onto my component via an initializer. It works great in development, but the property isn't present when I run tests. It appears that testing calls loadInitializers, but the dependency is not showing up on this.subject({}); I don't want to manually inject it for the tests. Is there a better way to handle this? Initializer: var FooServiceInitializer = { name: 'foo', initialize: function (container, application) { application.inject(

How to upgrade the Ember version in an Ember CLI application?

我的梦境 提交于 2019-12-22 08:44:46
问题 Assuming I created this Ember application last week: ember new shop cd shop ember install:addon ember-cli-scaffold ember g scaffold product name:string The console tells me that this application uses Ember 1.10.0: How can I upgrade this Ember application to Ember version 1.11.0? 回答1: The syntax has been updated to: bower install ember#2.0.0 --save-dev --save-exact 回答2: @Sukima's answer will work fine, but you can also use the ember-cli command: ember install:bower ember#<version> In your case

Ember Routing: Reusing a resource under multiple parent routes

半世苍凉 提交于 2019-12-22 08:38:59
问题 I have the following routing setup: this.resource('blog',function(){ this.resource('selectimage',{path:"selectimage/:returncontext"},function(){}); }); this.resource('post',{path:":post_id"},function(){ this.resource('selectimage',{path:"selectimage/:returncontext"},function(){}); }); What I would have expected is, when navigating to blog.selectimage and post.selectimage, that the same router,controller and view would be used. Unfortunately it seems that the last entry wins. Is it possible to

Ember.js input fields

醉酒当歌 提交于 2019-12-22 08:28:36
问题 Is it possible to use standard HTML5 input fields in an Ember.js view, or are you forced to use the limited selection of built in fields like Ember.TextField, Ember.CheckBox, Ember.TextArea, and Ember.select? I can't seem to figure out how to bind the input values to the views without using the built in views like: Input: {{view Ember.TextField valueBinding="objectValue" }} Specifically, I'm in need of a numeric field. Any suggestions? 回答1: EDIT: This is now out of date you can achieve

Ember.js - jQuery-masonry + infinite scroll

╄→尐↘猪︶ㄣ 提交于 2019-12-22 08:26:53
问题 I'm trying to get infinite scrolling and masonry working in my ember project. The masonry 'bricks' are posts with text and an image. Currently I can get the first page to show on the initial load of the page and apply masonry (I still have to do a setTimeout though, trying to figure out how to get rid of that as well). I also have the basic infinite scroll code in. For now I'm simply grabbing the second page from the back end. When scrolled to the bottom of the page the second page of posts

How to use md5.js within a compontent?

隐身守侯 提交于 2019-12-22 08:23:58
问题 I just started working with Ember-CLI 0.0.36 and I'm stuck with the Gravatar example code from the Ember.js homepage. I did > bower install --save JavaScript-MD5 > ember generate component gravatar-image Brocfile.js [...] app.import('vendor/JavaScript-MD5/js/md5.js'); [...] app/components/gravatar-image.js import Ember from 'ember'; export default Ember.Component.extend({ size: 200, email: '', gravatarUrl: function() { var email = this.get('email'), size = this.get('size'); return 'http://www

Route only loads on page refresh - Ember JS

安稳与你 提交于 2019-12-22 08:19:02
问题 I am currently learning Ember and I am making a simple app, but I have encountered a strange problem. I have a route setup and it only pulls the data when I reload the page. Here is my code: // Start Ember application App = Ember.Application.create({ LOG_TRANSITIONS: true }); // Router paths App.Router.map(function () { // Homepage this.resource('index', { path: '/' }); // Book view this.resource('book', { path: '/book/:id/:version' }); }); // Homepage route App.IndexRoute = Ember.Route

Replace parent view from child route

只谈情不闲聊 提交于 2019-12-22 07:05:04
问题 Following my question here Nested routes in Ember I would like to replace the view rendered from /settings/users/ with the view rendered by /settings/users/1 . My routes are defined as: Router.map(function() { this.route('login'); this.resource('settings', { path: 'settings/:settings_id' }, function() { this.route('overview'); this.route('users', function() { this.route('user', { path: ':user_id' }); }); }); }); My user.hbs template will render when users.hbs contains {{outlet}} . I want the

How to specify a dynamic root URL in Ember.js?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-22 06:45:32
问题 Ember allows for a root URL to be specified on the router here: http://emberjs.com/guides/routing/#toc_specifying-a-root-url App.Router.reopen({ rootURL: '/blog/' }); Is there a way to specify a dynamic URL like: /:region/:locale/ ? The rootURL assignment seems to only accept a literal string. Assets (including Ember) are being loaded from a common directory like /assets/ . 回答1: You can set rootURL dynamically within Router.init method, e.g. App.Router.reopen({ init: function() { // set