jQueryMobile List will not populate

I a trying to populate a jQueryMobile ListBox control, with entries from a table using the following code:

    var p=0;
    while(p<myNum){
    myList.addItem(String(myArrray[p]),"images/switch.png");
    p=p+1;
    }

The myArray item contains 4 rows of string data. I can verify that on Chrome console.
When I run the above code, only the 2nd and 3d item appear…

hi Dimitris,
what control are you using? I can’t see a “List Box” control under JQMobile, just a “List” control. I see a “ListBox” under the JQWidgets controls though. Please specify what exactly you’re using.
also please include what “myNum” is set to.
I tried a bit with the JQMobile “List” control, but got a javaScript error saying “myList.addItem is not a function”. not very helpful.

@Computerhusky, that error is fixed in the next build. The workaround is to turn on BASIC in Libraries.

It was a jQueryMobile List, sorry for the misnomer.
BR

@Dimitris, could you open a new topic? This is a new question.

Hi George,
I actually tried that too (turning on BASIC in Libraries). it still says myList.addItem(……) : myList.addItem is undefined.

This is with AppStudio 7.3.1.3 and testing with Safari on Mac (latest upgrade, Safari 12.1.1 on Mac OS 10.14.5).

I now upgraded to 7.3. now I get a script error in the console again:

TypeError: myList.addItem is not a function. (In ‘myList.addItem(myArray[p])’, ‘myList.addItem’ is undefined)

here’s the source code:

var myNum = 4;

var p=0;

var myArray=[“eins”,“zwei”,“drei”,“vier”];

console.log§;

while(p<myNum){

console.log(p+" : "+myArray[p]);

myList.addItem(myArray[p]);

p++;

}

So the „basic“ doesn’t seem to make much difference.

I then copied the complete „project“ and in the copy switched the language to BASIC.

new source code:

Dim myNum=4

Dim myArray(4)

myArray = Array(“eins”,“zwei”,“drei”,“vier”)

For p=0 To myNum

myList.addItem(myArray[p],“images/switch.png”,1)

Next

And it creates basically the same error when run :frowning:

Kind regards

Thomas

Hi Dimitris,
where did you put your code? I initially tried what you did (as you see above), directly in the code window, and got the same errors.
But then I put the whole code into the project like this:

Form1.onshow=function(){
  var myNum = 4;
  var p=0;
  var myArray=["one","two","three","four"];
  while(p<myNum){
    console.log(p+" : "+myArray[p]);
    List1.addItem(myArray[p]);
  p++;
  } 
}

And this worked. I did use the latest version of AppStudio.

Kind regards
Thomas