2013-07-23 30 views
2

是否Select2有任何onLoad事件,以便我可以設置一些默認值?現在,我使出一些醜陋伎倆Select2添加到Dom後Ember的didInsertElement的幫助:如何在Select2準備好時設置值?

`setTimeout(function() {$select.select2('val', id).trigger('change'), 500}); 

我敢肯定有一個更好的解決方案在那裏:)

回答

1

試試這個,它可幫助你,

$(document).ready(function() 
{ 
    $("<option value='0'>Default</option>").insertBefore("option:nth-child(1)"); 
}); 
相關問題