NormanL#16842
Hi,
I have two CanvasViewers on my page and I'm trying to execute a remote method against both in turn but I'm running into some problems and I think its because I'm not waiting for one opertion to complete before performing the next?
My client side function looks like the following:
I have two CanvasViewers on my page and I'm trying to execute a remote method against both in turn but I'm running into some problems and I think its because I'm not waiting for one opertion to complete before performing the next?
My client side function looks like the following:
function MyFunction(canvasViewerIds) {
var params = new Array();
params.push('param1', 'param2', '');
for (i = 0; i < canvasViewerIds.length; i++) {
params[2] = 'some value'; // value different for each pass; not shown for brevity
var canvasViewer = $find(canvasViewerIds);
canvasViewer.invokeRemoteMethod('MyRemoteMethod', params);
//alert('here');
}
}[/quote]
The function accepts an array of CanvasViewer ids (e.g. '_clientViewer1', '_clientViewer2'). The 'MyRemoteMethod' method updates a single CanvasViewer (e.g. changes the current image or similar).
If I pass just one id (i.e. '_clientViewer1' or '_clientViewer2') everything works as expected. However, if I pass both ids then only the second viewer is updated successfully. If I uncomment the alert above I get to it before the operation is complete (or at least before the canvas viewer is updated). How do I wait until I'm sure the first call has completed? I've seen reference to statusChanged event and get_status but I'm not sure (a) if they can help or (b) how to implement them in this case.
Any help would be gratefully received.
Thanks