Databound Canvas???

I have a Canvas that contains some images (photos). Is there any way, I can “load” the entire Canvas with its’ children (the photos Img objects) from DB? For instance, if a user needs to load a particular Album/Portfolio, they can select one and click on Load. This should load a Canvas with all the images preloaded. I am guessing I can do
isc.Canvas.create(canvasproperties) where canvasproperties contain all the properties including children attribute. The canvasproperties should probably be generated on the server. The question is: How do I load it via AJAX? The server can return data in any format js, json or xml (using ruby on rails).

UPDATE: I was able to use RPCManager to retrieve Javascript data from the server. However, I still have one small problem. I have a main Canvas “main”. In my server code, I return a JS with isc.Canvas.create({“child”, … children :}) and the RPCRequest is set to eval the output, so basically I do mainCanvas.addChild(data) and this works perfectly and I get this child canvas within the main canvas. The child canvas has a number of Img objects and they all show up fine.
However, what I’d ideally like is for those Img objects to become children of the “main” canvas. I tried doing mainCanvas.setProperty(“children”, data) (making sure that the server only returns [isc.Img.create(…), isc.Img.create(..) ]) and then a redraw, but it did not add it (the developer console Watch tab doesn’t list the Img objects are the children of main). In fact, these never get added anywhere.

What am I doing wrong? Is there another way to do this (is there a addChildren that I am missing)?

thanks.

If you are going to return an Array of Img instances, just iterate down in calling addChild().

By the way, simply returning the properties intended for Img widgets (eg src, width, height) in ordinary JavaScript Objects leaves you more flexibility on the client side. For example, you could use the properties to create Img widgets, or you could use the same set of properties with Canvas.imgHTML(), etc.

Here’s the format that I am now sending back.

        [
		isc.DroppedLogo.create({
			src: "/photos/photo1.jpg",
			width: 580,	height: 82, top: 0, left: 0, canDragResize: true
				}),
		isc.DroppedLogo.create({
			src: "/photos/photo2.jpg",
			width: 120,	height: 85, top: 0, left: 580, canDragResize: true
				}),
		isc.DroppedLogo.create({
			src: "/photos/photo3.jpg",
			width: 700,	height: 24, top: 82, left: 0, canDragResize: true
		})
]

This is being passed in to my callback as data (since I eval’ed it in RPCRequest). I thought data was just a string at that point, so didn’t bother looking for an array. Are you suggesting that I can do
for (elements in data…), main.addchild()?

Is the data format that I am passing back correct? thanks a lot.

There is no “correct” data format in an RPC, you can do whatever you want.

In this case you could eval() that String and it would give you an Array that you could then iterate down.

Or, as previously mentioned, you could simplify what the server is sending, omitting the DroppedLogo.create() calls, and omitting common properties (like canDragResize).