Select2 wirkt ganz anders, mit nicht abgefangene Abfrage-Funktion ist nicht definiert für Select2 <select2-id>

Lade ich die Werte für select2 wie die folgende Weise.

Deklarieren des Typs

var  AdjustmentType = Backbone.Model.extend({
            url : Hexgen.getContextPath("/referencedata/adjustmenttype")
    });

erstellen Sie eine Instanz für den Typ

var adjustmentTypes = new AdjustmentType();

laden der Werte zu select2 box

adjustmentTypes.fetch({
                    success : function() {
                        for(var count in adjustmentTypes.attributes) {
                            $("#adjustment-type").append("<option>" + adjustmentTypes.attributes[count] + "</option>");
                        }
                    }
                });  
                $("#adjustment-type").select2({
                     placeholder: "Select Adjustment Type",
                     allowClear: true
                 });

Mein HTML-Code

<div class="span4">
        <div>ADJUSTMENT TYPE</div>
        <select id="adjustment-type" tabindex="5" style="width:200px;">
            <option value=""></option>
        </select>
    </div>

als ich diesen laden zum ersten es gibt keine Ausnahme, aber wenn ich Refresh oder navigate to different URL bekomme ich die folgende exception:

Uncaught query function not defined for Select2 adjustment-type

InformationsquelleAutor Java Questions | 2013-07-08

Schreibe einen Kommentar