- This topic has 0 replies, 1 voice, and was last updated 11 years, 8 months ago by jim.
-
AuthorPosts
-
jimMemberHere’s an example of one of several bizarre behaviors my app was encoutering.
I have a function called populateDB which fires when you click a button and is supposed to write 2 records to the database and then populate a list dynamically.1st click of populateDB button – wrote 4 records instead of 2
2nd click of populateDB button – wrote 16 records instead of 2
3rd click of populateDB button – wrote 32 records instead of 2
4th click …. etc. etc.I have been trying to figure this out for a several weeks and today finally came up with a solution. The problems started when I had to use phoneui.preprocessDOM(screenid) to create a dynamic list with sqlite. My first bandaid solution (which really wasn’t a solution) was to modify the phoneui.preprocessDOM to not use the screenid but instead the id of the list I was dynamically updating. While it kind of worked, the flakey behavior was still hitting me in other parts of my app.
In desperation, I rewrote the app about 4-5 different ways with the same results so this was driving me nuts. Clicking the list to pop up an alert() was firing the alert() twice. Tried emailing M1 tech support but they never responded. So I kept plugging away until I figured it out because this was making me crazy.
SOLUTION:
change sqlite to NOT use a global variable when defining the db. Instead, everytime you need a database object, define it in the function where it’s needed. Surprisingly, this solved the problem. I can now use phoneui.preprocessDOM(screenid) and everything is stable once again.SOLUTION2: Something else I found is there seems to be a problem in the test center using Android. If you have events like onclick doubling up, first thing I would do is to try the test center in iphone mode and see if it happens there. Uploading to an android phone works … just the test center is sometimes flakey.
-
AuthorPosts