Hi
Ive followed the info here
http://www.genuitec.com/mobile/docs/javaScriptSnippets/javaScriptSnippets.html
relating to SelectLists
With ComboBox widgets it mentions about updating the “selected” attribute and then calling the preprocessDOM method on the page. However with the SelectLists it doesnt mention about how to set the defaults dynamically only how to get the values and text labels but as its held in a select list it seems logical that its similar to the ComboBox
Ive created a brand new page called test.mobi, I’ve added a selectlist with the default 3 items on it and I’ve named the selectlist “packageSelect”. Ive not altered the Ids on the 3 individual <li> items
In the documentreadyhandler I have the following:
alert($(‘select[name=”packageSelect”] :selected’).text());
$(‘select[name=”packageSelect”] option:last’).attr(‘selected’,’selected’)
alert($(‘select[name=”packageSelect”] :selected’).text());
phoneui.preprocessDOM(“#m1-test”);
The first alert shows “Item 1”
it then sets the select to the last item and the next alert shows “Item 3” so its successfully setting the select item
The preprocessDOM seems to be doing nothing as when it shows on screen despite telling me that Item 3 is now the selected item, it still shows Item 1 with a tick in it.
I’m obviously nearly there but I’m at a loss. Ive also tried
phoneui.preprocessDOM(“#m1-test-packageSelect”);
In the hope this might do something but to no avail.
Thanks in advance for any help or guidance. Ive searched the forums for “selectlist” but cant find anything relevant. This is running on 2.1.2
Tony