0
Ecg.Views.PacienteView = Backbone.View.extend({

    events:{
        "change #div_pacientes" : "buscar"
    },
    buscar: function(e){
        console.log('test');
        buscarHistorial();
    },  
    initialize : function(model){

        var self = this;
        this.model = model;
        this.model.on('change', function(){
            self.render();
        });

    },
    render: function(data) {

        var pac_select_template = _.template($("#ListaPac_tpl").html(), {
            coleccion: window.collections.pacientes.toJSON()
        });
        $('#div_pacientes').html(pac_select_template);
        return this;
    }
});

これが私のテンプレートです

<script id="ListaPac_tpl" type="text/template">

    <select id="sel_paciente" name="sel_paciente" >

        <% _.each(coleccion,function(paciente) { %>
            <option value="<%= paciente.cedula %>">
                <%= paciente.nombre %>
            </option>
        <% }); %>
    </select>

</script>

これが結果です。

<label>Pacientes:</label>
<div id="div_pacientes">        
    <select id="sel_paciente" name="sel_paciente">
            <option value="91520731">   Josue   </option>
            <option value="123456"> joshua  </option>
    </select>
</div>
<div apellidos="barrios" nombre="joshua" cedula="123456"></div>
<div apellidos="Barrios Rodriguez" nombre="Josue" cedula="91520731"></div>

質問:

  1. div 'div_pacientes' の後にアンダースコアまたはバックボーンの繰り返しデータを使用するのはなぜですか??
  2. バックボーンが「バスカー」関数でイベントの変更をバインドしないのはなぜですか??

前もって感謝します

PD: 開発者の日おめでとう

4

0 に答える 0