d1984
14 Sep 2011, 6:32 AM
I have the following code attached as a handler to a button:
myapp.stores.vehicleInfo.load();
myapp.toolbars.vehicleInfoToolbar.setTitle('Image 1 of ');
Which within my defined namespace loads the store and then sets the title of a toolbar - this works.
This code doesn't work:
myapp.stores.vehicleInfo.load();
myapp.toolbars.vehicleInfoToolbar.setTitle('Image 1 of'+ myapp.stores.vehicleInfo.data.items[0].data.imageTotal);
giving the error: 'cannot read property of "data" of undefined'
But when I click the button a second time, it sets the title of the toolbar as expected e.g. Image 1 of 10.
What is going on here? How do I solve this? I tried using the settimeout method in case the setTitle method was being called too early before the store was finished loading. However this failed to solve the problem.
Many thanks.
myapp.stores.vehicleInfo.load();
myapp.toolbars.vehicleInfoToolbar.setTitle('Image 1 of ');
Which within my defined namespace loads the store and then sets the title of a toolbar - this works.
This code doesn't work:
myapp.stores.vehicleInfo.load();
myapp.toolbars.vehicleInfoToolbar.setTitle('Image 1 of'+ myapp.stores.vehicleInfo.data.items[0].data.imageTotal);
giving the error: 'cannot read property of "data" of undefined'
But when I click the button a second time, it sets the title of the toolbar as expected e.g. Image 1 of 10.
What is going on here? How do I solve this? I tried using the settimeout method in case the setTitle method was being called too early before the store was finished loading. However this failed to solve the problem.
Many thanks.