Page 2 of 2

Select Dropdown Problem

Posted: Sun Feb 08, 2015 6:42 pm
by M&M

Assuming that you are saving the value of the previously selected item, you can pre-select it this way

code
var lsvPrevSelectedItemVal = localStorage.getItem('custPrevSelValueFromDb');
// Remember to change the select component name
Apperyio("mobileselectmenu_20").val(lsvPrevSelectedItemVal).selectmenu('refresh');
/code

You can call this code after the REST Success call so that it executes it after the Select component has been populated with values. As an added measure you may want to do some error handling in case the previously selected item is no longer available / deleted etc


Select Dropdown Problem

Posted: Sun Feb 08, 2015 7:10 pm
by Ellen Schlechter

The problem I found with that code is that I need to tap on the page or click on the select menu and click away and it will refresh the the menu. I want it to be automatically there instead of a user invoked refresh of some sort.


Select Dropdown Problem

Posted: Mon Feb 09, 2015 12:21 am
by She

Hi M&M,
there's an error in refresh:

Image


Select Dropdown Problem

Posted: Mon Feb 09, 2015 7:16 am
by M&M

tried that in REST complete event? Use a flag that you reset in the on before event. Update with values 1 and 2 for success and failure respectively. In your complete event check for 1 (success) and then use the code to select the first value. I believe you are getting the error because it's either in the process of loading values, or the process is not compelete yet


Select Dropdown Problem

Posted: Mon Feb 09, 2015 8:36 am
by She

Hi M&M&,
yes i already tried this in rest complete event. but still no luck :(
Thank you,


Select Dropdown Problem

Posted: Mon Feb 09, 2015 8:56 am
by She

Hi M&M,
Thank you for your idea
i used this code $('select[name="Drop1"]').get(0).selectedIndex = 0;
in complete event.

Thank you very much!