- This topic has 2 replies, 2 voices, and was last updated 12 years, 2 months ago by dynorodney.
-
AuthorPosts
-
dynorodneyMemberHi
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 itemThe 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
support-octavioMemberHi Tony,
In next topics you can find the solution for your request:
http://www.genuitec.com/support-genuitec/viewtopic.php?p=8909#p8909
http://www.genuitec.com/support-genuitec/viewtopic.php?f=8&t=3427
dynorodneyMemberOctavio
Many thanks. Couldn’t see those on a selectlist search of the forum but you are indeed a top man. Based on your example code, I’m writing up a little “set defaults for select list” function which might help others that, like me have values they want to use to identify the defaults and set both the select elements and the visual <li> elements in the same function. Ive written it, I just need to test it so i’ll copy it in here when its done
Thanks again
Tony
-
AuthorPosts