your default value is "default" whereas it should have your default value unless your default really means the word "default"
your default value is "default" whereas it should have your default value unless your default really means the word "default"
My default value depends on what a user has saved in the database.
So after populating the component with value from the database, fetch the default value the user saved in the database and then set the value of the component to the default value you retrieved from the database
I'm sorry but how do I do that?
Assuming that you retrieved the default value the user had previously saved into a variable called "PreviouslySelectedValue". Then your code to set the default value of the select component will be (Assuming that you already populated the select component).
If you had saved the previously saved value in a local storage variable you can retrieve it with
var PreviouslySelectedValue = localStorage.getItem('lsvPrevSelection');
// Change "SelectComponentName" accordingly
var selectComponent = Appery("SelectComponentName");
selectComponent.val(PreviouslySelectedValue);
selectComponent.selectmenu('refresh', true);
Btw you may want to confirm that the default value does exist in the select list before setting the default
Now in the select menu, it doesn't show anything as the default. It is blank and if you click it, you will then see options.
Do this -
// Change "SelectComponentName" accordingly
var selectComponent = Appery("SelectComponentName");
selectComponent.val("HARD_CODE_ANY_EXISTING_VALUE_HERE");
selectComponent.selectmenu('refresh', true);
What the above does is to use a known / hard- coded value. Check if this results in a value being selected?
So using that code, it works almost right. After I use the select menu to update that field, it switches back to the value that it was before. Then if I just tap the select menu then tap away to close it without selecting any other value, it will refresh and show the correct value. How can I fix this?
Hello Ellen!
1) Please try to move that code on page show event.
or please note
2) After your mapping is done, new values will not remove it
or
3) If value are hardcoded, you can add this value in the editor
I only understood the first but when I tried it, it didn't work.