I'm using Silvio Moreto's Bootstrap Select.
On my page I have a button that opens a modal with an input box that allows you to add an item to the selectpicker. I would then like to automatically have that item selected but I can't get it to work.
The code I have is :
$('#myselect').append('<option val='+newitemnum+'>'+newitemdesc+'</option>');
$('#myselect').val(newitemnum);
$('#myselect').selectpicker('refresh');
But it just doesn't work. The item doesn't get selected.
I have tried replacing the selection line with :
$('#myselect').selectpicker('val',newitemnum);
but that doesn't work either
Any ideas much appreciated (although the item DOES get added to the selectpicker).