2

Does Select2 have any onLoad event so that I can set some default value? Now I resorted to some ugly trick after Select2 is added to the Dom with the help of Ember's didInsertElement:

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

I'm pretty sure there is a better solution out there :)

cathulhu
  • 641
  • 1
  • 9
  • 20
wryrych
  • 1,765
  • 4
  • 20
  • 31

1 Answers1

1

Try this, it may help you,

$(document).ready(function() 
{
  $("<option value='0'>Default</option>").insertBefore("option:nth-child(1)");
});
n8coder
  • 691
  • 4
  • 12