facebook

SelectList Widget – setting defaults dynamically: CLOSED

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #330017 Reply

    dynorodney
    Member

    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

    #330019 Reply
    #330041 Reply

    dynorodney
    Member

    Octavio

    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

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: SelectList Widget – setting defaults dynamically: CLOSED

You must be logged in to post in the forum log in