ember.js

Emberjs, data-source, twitter bootstrap typeahead

拟墨画扇 提交于 2019-12-21 05:46:31
问题 While this may be specific to the "typeahead" situation, and my example has static content, really this would apply to any bootstrap usage of "data-source". I want to someday when I grow up use dynamic content for my typeahead implementation, so am trying the binding way for now: Ember.TextField.reopen({ //add some bootstrap specific stuff attributeBindings: ['data-provide', 'data-items', 'dataSourceBinding:data-source'], 'dataSourceBinding': Ember.Binding.oneWay('App

Adding New Ember.js Objects/Records when DB Provides ID

陌路散爱 提交于 2019-12-21 05:40:58
问题 I'm experimenting with Ember.js, Node.js and MongoDB. I've based my noodling on the excellent video on the Ember site and Creating a REST API using Node.js, Express, and MongoDB. I've hit a roadblock on the Ember.js side trying to get my create record functionality working. Currently, when a user creates a record in my sample application, two will show up in the listing. This is happening because when I save my record to the server, a new ID is created for that record by MongoDB. When the

Animate view states in State Manager

微笑、不失礼 提交于 2019-12-21 05:38:15
问题 I have a State Manager implementation with 2 view states. I want to defer the normal removal of a state and add a custom animation when the view is being destroyed and State Manager is transitioning to another state. Here is a jsFiddle: http://jsfiddle.net/Xkg6X/ For some reason, hide function of each view state is not being triggered where I can create a custom animation for removal. Reference: Deferring removal of a view so it can be animated 回答1: You don't ever call the hide function, so

Ember-data: deserialize embedded model

拥有回忆 提交于 2019-12-21 05:35:33
问题 I really don't get it here... I have the following code: App.Instance = DS.Model.extend({ hash: DS.attr('string'), users: DS.hasMany('user', { embedded: 'always' }) }); App.User = DS.Model.extend({ name: DS.attr('string'), color: DS.attr('string'), lat: DS.attr('number'), lng: DS.attr('number'), instance: DS.belongsTo('instance') }); App.InstanceSerializer = DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, { attrs: { users: { embedded: 'always' } } }); And instance like so: var instance = {

How to access array data hidden in a DS.PromiseArray

限于喜欢 提交于 2019-12-21 05:32:13
问题 This is a follow up to: accessing another models data in ember.js I have a situation where I would like to filter a list with a chosen multi-select box. When sending the data, this.store.find('tag') always returns a DS.PromiseArray. The Ember.Select seems to handle this fine, but the chosen multi select doesn't seem to like it. I have seen something like this: this.store.find('tag').then(function(items) { return items.map(function(item){ return [item.get('id'), item.get('name')] }) }) but I

How to do a like filter with ember.js

ぐ巨炮叔叔 提交于 2019-12-21 05:31:13
问题 I have a simple ArrayController in ember pre 1.0 and found that I can chop the list down if the filter finds an exact match for a given property, but what I can't seem to find is how do a "like" query with filter. What I have below works if I search an array with users... filtered = ['id', 'username'].map(function(property) { return self.get('content').filterProperty(property, filter); }); ... and a few of the users have the same username. For example => if I search / filter by "smith" it

How to debug Ember data's find in the console

孤街浪徒 提交于 2019-12-21 04:56:48
问题 With this post, I learned that I can use find in the console. But I'm having some problems using this to look up the data in my litte jsbin Ember.js with Ember Data and LSAdapter App here. Please add some orgs Please open your chrome console to see more details. Please type in App. container .lookup('store:main').find('org').toArray() Why does it show an empty array ??? Thank you so much for helping out 回答1: It's because find returns promises now App.__container__.lookup('store:main').find(

is handling custom server side errors in ember-data when saving model possible

与世无争的帅哥 提交于 2019-12-21 04:52:09
问题 Is there proper way to handle custom error when saving a model? To give an example, lets say I have a model with just two properties "name" and "value". And when I do : var myModel = this.get('store').createRecord('myModel', {"name": "someName", "value": "someValue"}); myModel.save().then(function() { //if success //server responded with {"myModel:{"id":1,"name":"someName","value":"someValue"}"} },function() { //if failure //server responded with {"error":"some custom error message"} //BUT

Ember computed properties with arguments

走远了吗. 提交于 2019-12-21 04:33:16
问题 I was wondering if it was possible to add arguments to a computed properties. So far, everything I tried resulted in errors and found nothing on the subject. I want to build a URL using a value that is not included in my model. I'm looking for something that would look like this : // App.js App.Image = DS.Model.extend({ image_path_sh: DS.attr(), // image.jpg image_size_nm: DS.attr(), // 234234 image_alt_sh: DS.attr(), // My image image_abs_url: function(width, height) { return "http:/

In an Ember.js Handlebars template, is there a way to have both static and dynamic class attributes?

余生长醉 提交于 2019-12-21 03:54:31
问题 Using the already-overused to-do app example, let's say I want an element with a "todo" class (static) and an "is-done" class (dynamic): <div {{bindAttr class="todo isDone"}}> Other stuff in here </div> In this case, "isDone" and "todo" are both expected to be properties on my view object, which is what I want for "isDone", but not for "todo". I'm currently working around this by adding a "todo" property on my view that is equal to a static "todo" string. Is there any way to have a static