I valori di caricamento per select2 sono come indicato di seguito.Select2 si comporta in modo molto diverso con la funzione di query non verificata non definita per Select2 <select2-id>
dichiarare il tipo
var AdjustmentType = Backbone.Model.extend({
url : Hexgen.getContextPath("/referencedata/adjustmenttype")
});
creare l'istanza per il tipo
var adjustmentTypes = new AdjustmentType();
carico di dialogo i valori da select2
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
});
mio codice HTML
<div class="span4">
<div>ADJUSTMENT TYPE</div>
<select id="adjustment-type" tabindex="5" style="width:200px;">
<option value=""></option>
</select>
</div>
quando carico questo per la prima che non sta dando alcuna eccezione, ma se mi Refresh
o navigate to different URL
ottengo la seguente eccezione:
Uncaught query function not defined for Select2 adjustment-type