Problema extraño con Ember.Select

I have a really weird issue with Ember.Select, I am using a same Ember.Select in two different templates and both are backed by two different controllers. But I get the list of teams in only . Ember.Select.

First place where it's trabajando es la siguiente:

<script type="text/x-handlebars" data-template-name="twoduser">
        <!-- more Info-->

        <div class="span3 pull-left" id="moreinfo2">
        <div class="row">
            <b>Full Name:</b> {{firstname}} {{lastname}}
            <br/>
            <b>Email:</b> {{email}}
            <br/>
            <b>Address:</b> {{address}}, {{city}}, {{state}}, {{country}}
            <!--<br />
            City: 
            <br/>
            State/Province: 
            <br/>
            Country:
            <br/> -->
            <br/>
            <b>Phone:</b> {{phone}}
            <br/>
            <b>Experience:</b> {{experience}}
            <br/>
            <b>Designation:</b> {{designation}}
            <br>

            {{view Ember.Select
        contentBinding="team"
        optionValuePath="content.team_name"
        optionLabelPath="content.team_name"
        selectionBinding="selectedTeam"
        prompt="Please Select a Team"}}
            <button class="btn" {{action 'addToTeam' }}>Add To Team</button>
        </div>
        </div>
        </script>

Corresponding controller:

App.TwoduserController = Ember.ObjectController.extend({
    selectedTeam : null,
    team : function (){
        var teams = [];
        $.ajax({
            type : "GET",
            url : "http://pioneerdev.us/users/getTeamNames",
            success : function (data){
                for (var i = 0; i < data.teams.length; i ++){
                    var teamNames = data.teams[i];
                    teams.pushObject(teamNames);
                }
            }
        }); 
        return teams;
    }.property(),
});

The second place where it's no funciona:

 <script type="text/x-handlebars" id="teammembers">
        <div class="row-fluid">
        <div class="span3 offset3">
            <div class="row-fluid">
                <div class="span12">
                <h4>Your Team Members</h4>
                {{view Ember.Select
                contentBinding="team"
                optionValuePath="content.team_name"
                optionLabelPath="content.team_name"
                selectionBinding="selectedTeam"
                prompt="Please Select a Team"}}
            <ul>
                <li>
                {{#each item in arrangedContent}}
                    {{#link-to 'teammemberdetail' item}}{{item.firstname}}, {{item.team_name}}{{/link-to}}
                    <br>
                {{else}}        
                    <p><b>Nothing there</b></p>        
                {{/each}}
                </li>
            </ul>
                <button class="btn"
                {{action 'generate'}}>Get Team Members PDFs</button>
                </div>
                </div>
                <div class="row">
                    <div class="span12 offset5">{{outlet}}</div>
                </div>
                </div>
            </div>
        </script>

Corresponding controller:

    App.TeammembersController = Ember.ObjectController.extend({
        selectedTeam : null,
        team : function (){
            var teams = [];

            $.ajax({
                type : "GET",
                url : "http://pioneerdev.us/users/getTeamNames",
                success : function (data){
                    for (var i = 0; i < data.teams.length; i ++){
                        var teamNames = data.teams[i];
                        teams.pushObject(teamNames);
                    }
                }
            }); 
            return teams;
        }.property(),
});

I am getting the list of names in the later one. Why it might be happening?

preguntado el 27 de noviembre de 13 a las 05:11

1 Respuestas

Deberías usar un Route to retrieve data from your backend and set them in the controller (look the guide about the ember routes).

Then you should not have the content. part of path in the optionValueBinding y optionLabelBinding.

Finally you should better use the {{select}} Handlebars helper from Ember.

respondido 27 nov., 13:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.