Hi, I have a very simple setup - I have 2 texts and 2 gallery pros on my page, if I try to change the items in my gallery when it is inside an object in an array - it doesn’t work. Here is an example:
var myArray = [
{ item : $w ( ‘#text1’ ), gallery : $w ( ‘#gallery1’ )},
{ item : $w ( ‘#text2’ ), gallery : $w ( ‘#gallery2’ ) }
]
$w . onReady ( function () {
myArray [ 0 ]. item.text = “hello” ; //this works
myArray [ 0 ]. gallery.items = [] // this doesn’t work
console . log ( “hi” ); // this works
});
In contrust this does work:
//this all works
var myArray = [
{ item : $w ( ‘#text1’ ), gallery : $w ( ‘#gallery1’ )},
{ item : $w ( ‘#text2’ ), gallery : $w ( ‘#gallery2’ ) }
]
$w . onReady ( function () {
myArray [ 0 ]. item.text = “hello” ;
$w ( ‘#gallery1’ ). items = [];
console . log ( “hi” );
});
And finaly the wierdest:
var myArray = [
{ item : $w ( ‘#text1’ ), gallery : $w ( ‘#gallery1’ )},
{ item : $w ( ‘#text2’ ), gallery : $w ( ‘#gallery2’ ) }
]
$w . onReady ( function () {
myArray [ 0 ]. item.text = “hello” ; //this works
myArray [ 0 ]. gallery.items = [] // this doesn’t work
$w ( ‘#gallery1’ ). items = []; //now this also doesn’t work
console . log ( “hi” );//this works
What am I doing wrong?