- This topic has 14 replies, 6 voices, and was last updated 11 years, 8 months ago by
support-octavio.
-
AuthorPosts
-
BrianJaydienMemberHello Everyone,
I’m new to MobiOne and programming iPhone apps in general, but I really love this program.
My question is as follows:
I am gathering user data such as name, email, gender, height weight, etc… & storing it in LocalStorage. I have that part down and it seems to be working. I then recall that data when the document loads and populate the text fields with the appropriate localstorage data.
Stores the data:
localStorage.setItem('LSName',$('#m1-Daily_Meal_Tracker-name').val()); var namefield = $('#m1-locstorage-LSName').val();
Recalls The data:
$('#m1-Daily_Meal_Tracker-name').val(localStorage.getItem('LSName'));
My problem is that the Combo Boxes do not show the value the that is being pulled from localstorage until you click on it, then you can see the proper selection with a check next to it.
Is there any way to have it show the selection with the check next to it when the document is loaded. It’s a little confusion the way it is right now as the user won’t think the data has been saved until they click the actual combobox.
Also, is localstorage data saved when the app process is removed from memory or the phone is rebooted?
Thanks.
Brian
Stu WadeMemberSeems we have the same problem.
My post is here http://www.genuitec.com/support-genuitec/viewtopic.php?f=8&t=5380
I don’t have an answer yet, but I think we should keep an eye on both topics.
BrianJaydienMemberYeah seems as though it is something silly that we’re missing.
In HTML, you can programmaticaly (Not sure how to spell that) tell the browser to show that a particular item is selected based on Database query results, etc… This is sort of the same concept, but looks like the selected value that is preset in the designer fdr the combobox is over-riding the value set by the Javascript code.
The joys of programming.
-Brian
BrianJaydienMemberAnyone???
support-octavioMemberHi Brian,
Please take a look at this post with a similar question, you should just adapt a little your code to load the content of localStorage.
http://www.genuitec.com/support-genuitec/viewtopic.php?f=9&t=4323
Stu WadeMemberHi Octavio,
Thanks for the above. Sadly I have tried changing the DOM reference to the combo box name as you suggested and still no joy. My original query is linked in my post above in this thread.
BrianJaydienMemberSame here. That had no effect.
-Brian
BrandonMemberTry this. Will populate the combo box using the key as the combo text
Attachments:
You must be logged in to view attached files.
Stu WadeMemberThanks CincyPlanet – but again no joy …
Your example gives a compiler error
“TypeError: Result of expression ‘lCombo’ [null] is not an object.”Sadly, my knowledge of JavaScript is not upto debugging this. Were it to work, your approach seems to be just the ticket for my App. Is the use of LocalStorage required actually required for this approach to work, or just to make it fit Brian’s situation better?
BrandonMemberTry installing the latest Dev build from here:
https://docs.google.com/file/d/0B2UbQ9Htq1UWWjVUX3RnbzVkQUU/editIve noticed the changes they have made have been affecting a lot of my samples for older versions.
Publio DecioMemberDo you have any idea of how to change the labels of the combobox at runtime?
For example in the case of APP multi language.
The example you entered does not work, i’ve the 2.5 dev-5.
I entered my code 4 exampleThank You
Alessandrofunction Combo(container_id, comboData)
{
var lCombo = $(‘ac-mtchome-hidden-select-‘ + container_id);
lCombo.remove(0);
lCombo.length = 0
lCombo.selectedIndex = 0;
var noOfOptions = comboData.length;
for (var i = 0; i < noOfOptions; i ++ )
{
var oOption = document.createElement(“option”);
oOption.text = comboData[i];//item;
oOption.value = i;
lCombo.add(oOption);
}
}
support-octavioMemberHi Alessandro,
Next example provided by dev team should be helpful for you.
Attachments:
You must be logged in to view attached files.
Publio DecioMemberPerfect !!!
Thank you
Alessandro
egroj90MemberHi, i saw the example, but how can i achive the same thing on pageload, how can i populate the combobox on page load?
Hugo Silva
support-octavioMemberHi Hugo,
If you want the combobox is populated when the app is lanched you should put the code that populate the combobox in the phoneui.documentReadyhandler function that it’s on your www-appName/appName_custom.js file. If you want to do it when a page is loaded you ought to put the code in the prePageTransition function. Hope this make sense.
-
AuthorPosts