Selects, promises, ember-data and I'm crazy

Hello Everyone,

Since I start developing with Ember, I’ve got problems with select, usually I solve it with something, but Today I found my problem, and now I don’t know what is the best solution.

The problem is:

I define call the view select with that:

{{view "select" value=model.parent
		prompt="Select group"

And I’ve got the list of elements for the view using a… like that:

listGroups: function (){

My problem is: when emberJS show the view, It loads parent.model, when it see that parent.model is non existing on listGroups because it doesn’t exist, it changes or ignores (I don’t know exacly, because the changes don’t appear on other views) and when the listGroups load, it don’t know the correct value.

Now, I made a variable that is idGroup, and put value=idGroup, etc… But I don’t know if it’s the best solution.


Edit: Sorry, You can look one of my projects that I’ve got this problem in GitHub - Dracks/password-manager-emberjs: The view with EmberJS for the project password-manager-django (I change a little things on the code for the post, but it’s based on password-manager-emberjs/edit.js at master · Dracks/password-manager-emberjs · GitHub and password-manager-emberjs/edit.hbs at master · Dracks/password-manager-emberjs · GitHub )

The select view doesn’t play nicely with promises unfortunately.

I’ve solved this in the past by resolving the promise in the route on the model hook (i.e. the model is a hash, of which one attribute is the resolved listGroups.) Then the template can pass the resolved listGroups directly into the select.

Thank you!

Yesterday I was playing with select view all the day, and I found that the last version of Ember, works better with promises, but with old versions, I should take the list and found the object inside the list to put on selection, like this:

selected_language: function (){
    var language=this.get('');
    if (language!=null){
        language = this.get('language_list').find(function (e){
            return e.get('id')==language;
    } else {
        language= this.get('language_list.0');
    return language;
}.property('model.language', 'language_list.content')