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, 3 voices, and was last updated 12 years, 1 month ago by
billPeach.
-
AuthorPosts
-
billPeachMemberCan you please help me with this
I have trawled the Blog and cheat lists, using snippets where available, but cannot get this to work I have created a sample attached to demonstrate the problemI am trying to populate a select list dynamically with data ( represented with an array) which I successfully can do loading the text into the text field, but it seems that I am not loading the val field. When I try to select the item which loads into a text field I get the val of the original Selectlist rather than the newly loaded one
I have racked the brain on this one for days now and have just reached a block
Are you able to point me in the right direction or give me an example or tell me where I am going wrong!!!
Frustrated
Bill Peach
Attachments:
You must be logged in to view attached files.January 26, 2014 at 7:11 am #346407
Code_AMemberWe are in the same boat here as I am struggling with the exact same issue right now! Seems like it shouldn’t be that difficult. See my last 2 posts in this thread viewtopic.php?f=8&t=6752
I will be watching your post to see if you get this resolved. If I figure something out, I’ll let you know. Sorry, I can’t help.
January 26, 2014 at 8:16 am #346412
billPeachMemberThanks for reassuring me that it may not be my code
This has been driving me nuts!!
Any clues out there!!!
January 30, 2014 at 10:00 am #346548
Code_AMemberApparently this issue may be a bug that the dev team is now investigating. See viewtopic.php?f=8&t=6752.
January 30, 2014 at 11:11 am #346556
billPeachMemberThanks Code A
It is reassuring that I am not a complete coding ‘fruit loop’. I have spent hours on this!
It is good to know that it is being looked at and looking forward to an ETA for a fix or workaround
January 30, 2014 at 12:30 pm #346563
Code_AMemberYou can see the updated example that the support team posted that makes this work at viewtopic.php?f=8&t=6752.
Basically, there are 3 lines of code that need added to the function that dynamically builds the list. I have indicated them below as ‘<—NEW!’:
// Array of items to fill SL var items = ["First", "Second", "Third"]; // Selected item index var selItemIndex = 0; var $selectionList = $('#m1-sl-filling-list1'); // Store old items (will remove them later) var olditems = $selectionList.children(); // First of old items is our template var templ = $(olditems[0]); // "<select>" element var $select = $('#' + $selectionList.attr('data-hiddeninputid')); //<--- NEW! $select.empty(); //<--- NEW! // Do for each data item $.each(items, function(i, val) { // Clone template var clone = templ.clone(); // Set correct value for "first" class clone[(i == 0) ? "addClass" : "removeClass"](m1Design.css('first')); // Set correct value for "last" class clone[(i == (items.length-1)) ? "addClass" : "removeClass"](m1Design.css('last')); // Process selected item clone[(i == selItemIndex) ? "addClass" : "removeClass"](m1Design.css('selected')); // Set "value" item (it will be set to <select><option VALUE> attribute when doign POST to server) clone.attr('data-val', "val" + i); // Set text label clone.find('label').text(val); // We're done, add element to list item clone.appendTo(templ.parent()); $select.append("<option value='" + val + "'>" + val + "</option>"); //<--- NEW! }); // Remove old items olditems.remove(); // Don't forget to sync internal phoneui state phoneui.preprocessDOM(phoneui.getCurrentPageId());And then this is how you retrieve the selected value:
alert("Val: " + $('select[name="list1"] :selected').val())January 30, 2014 at 12:41 pm #346565
support-octavioMemberHi Code A,
Thanks for sharing updated example on this thread with the same issue.
Feel free to ping us if you need further assistance.
January 30, 2014 at 1:22 pm #346574
billPeachMemberThanks Octavio
Seems to have resolved it
I will now plug it into the main and check it works
-
AuthorPosts
