For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub
- This topic has 7 replies, 2 voices, and was last updated 12 years, 2 months ago by
KariSolamaki.
-
AuthorPosts
-
Code_AMemberI am playing around with my first native app in Mobi and I am trying to update a selection list based on user input. I have found some code on the forums, but much of it seems to be more complicated than what I need (at least that appears to be the case).
Here are the widgets I have on my screen with the names and values:
Select List Menu: lstNumbers>Items[1,3,5,7,9]
Select List Menu: lstEvenOdd>Items[Even, Odd]Here is what I want to happen:
When the user selects ‘Even’ from lstEvenOdd, I want to modify the existing items (text and value) in lstNumbers to [0,2,4,6,8].
When the user selects ‘Odd’ from lstEvenOdd, I want to modify the items (text and value) in lstNumbers back to [1,3,5,7,9].Seems like a simple function to overwrite (or edit) of the values in the list is all that is needed but I am not sure how to access the elements the proper way through Javascript. A quick example would be much appreciated.
Thanks!
December 24, 2013 at 7:01 am #345482
Code_AMemberI am trying to use jQuery to do this but the values do not seem to be updating.
Here is an example of the code I am using to update the list items:
$('#m1-Project-lstNumbers option:eq(1)').val('2'); $('#m1-Project-lstNumbers option:eq(1)').text('2');December 24, 2013 at 2:22 pm #345490
KariSolamakiMember@Code A wrote:
I am trying to use jQuery to do this but the values do not seem to be updating.
Here is an example of the code I am using to update the list items:$('#m1-Project-lstNumbers option:eq(1)').val('2'); $('#m1-Project-lstNumbers option:eq(1)').text('2');Ok, lets assume we have page MyScreen with list myList.
List has itemOne and itemTwo with values 1 and 2 and texts ‘One’ and ‘Two’.
Lets change the values into 10 and 20…$('#m1-MyScreen-itemOne').val('10'); $('#m1-MyScreen-itemOne').text('Ten'); $('#m1-MyScreen-itemTwo').val('20'); $('#m1-MyScreen-itemTwo').text('Twenty'); phoneui.preprocessDOM('#m1-MyScreen-myList'); // this is important!!December 24, 2013 at 8:41 pm #345492
Code_AMemberThank you for the reply, but I am still not able to get it to work as I hoped. It appears that maybe you are using a Select List, I am using the Select List Menu widget and cannot seem to access the list items through the syntax you have provided. It seems I need to access the items through an array or by index somehow.
In the example below, lstNumbers is the name of the select list menu. How do I access the items in the menu list? jQuery provided the method below but it does not appear to be updating the items at runtime.
$('#m1-Project-lstNumbers option:eq(1)').val('2'); $('#m1-Project-lstNumbers option:eq(1)').text('two'); phoneui.preprocessDOM('#m1-Project-lstNumbers');Thanks for your help!
December 26, 2013 at 3:37 pm #345518
KariSolamakiMember@Code A wrote:
…, I am using the Select List Menu widget and cannot seem to access the list items through the syntax you have provided.
It seems I need to access the items through an array or by index somehow…Check out the TestListMenu.mobi attached…
I did get the text and value changed, but updating the List Menu doesn’t work as I thougth.Attachments:
You must be logged in to view attached files.December 26, 2013 at 4:37 pm #345522
Code_AMember@Einotes Team wrote:
I did get the text and value changed, but updating the List Menu doesn’t work as I thougth.
Thank you for your continued support.
This does not seem like it should be a complicated task to handle programmatically. I have tried dozens of methods to access and update the list items by index, but all to no avail. I just can’t get the list items to update. Frustrating.
As an alternative, I do have some code (from these forums) that completely tears down and rebuilds the list programmatically.
What is the correct method for “refreshing” my screen/widget after changing the attributes? I have seen many different methods and I do not understand the differences. Below are few examples:
phoneui.preprocessDOM(phoneui.getCurrentPageId()); phoneui.preprocessDOM(); phoneui.preprocessDOM('#m1-Project-MyList'); phoneui.preprocessDOM($('#m1-Project-MyList').parent().parent());December 26, 2013 at 10:21 pm #345527
KariSolamakiMember@Code A wrote:
What is the correct method for “refreshing” my screen/widget after changing the attributes?
I have seen many different methods and I do not understand the differences.
Below are few examples:phoneui.preprocessDOM(phoneui.getCurrentPageId()); phoneui.preprocessDOM(); phoneui.preprocessDOM('#m1-Project-MyList'); phoneui.preprocessDOM($('#m1-Project-MyList').parent().parent());In post “Select-List-Menu – getting and setting values” 30 Nov 2011, 16:12 support-wayne wrote as follows:
There is some quirk that is causing issue with a programmatically updated list or selection.
I am discussing with the dev team now.
I have code that updates the list which works but there is some degradation that transpires after updating the list or selection.Support needed! Wayne or Octavio, has this problem been fixed?
December 27, 2013 at 12:53 am #345532
KariSolamakiMemberChange in SelectListMenu MenuLabel updates normally…
List items texts and vals can be changed, but not seen in the list.
When changing selected listitem and going back to mainscreen
the listitem label is changed, but not any visible change in the list????Attached the modified TestListMenu.mobi
Attachments:
You must be logged in to view attached files. -
AuthorPosts
