我的页面上有以下选择:
<select><option value="1" selected="selected">Caption</option></select>
我调用 select2 (v 4.0) init:
city.select2({
ajax: {
url: <...>,
data: <...>,
processResults: <...>,
cache: true
},
escapeMarkup: function(markup){ return markup; },
minimumInputLength: 0,
templateResult: function(repo){ return repo.name; },
templateSelection: function(repo){ return repo.name; }
});
问题是 select2 正在重置默认选定值并显示空白字符串。有没有办法在 select2 init 上设置默认值?