On Fri, Mar 28, 2008 at 3:46 PM, Ken Tilton kennytilton@optonline.net wrote:
Andy Chambers wrote:
On Fri, Mar 28, 2008 at 3:15 PM, Ken Tilton kennytilton@optonline.net wrote:
$("#my-id").html("Hello World");
Translated, that means find the html element with id "my-id" and set the html inside it to be "Hello World". If I can just keep track of all the little changes, I'll send a list of these commands to be eval'd on the client.
Coolio. I am about to send something with the OpenGL version to help with some ideas.
Question: Can you feed #my-id to the browser and then reference it later in a page send? Or must it originally arrive as part of a larger X/HTML tree, only after which it can be referred to directly?
If you mean "Do all id's have to be known up front?".
No, I meant /can they be/ defined up front, or <gasp> even later in one stream. ie, as long as all the pieces are in place (as identified by ID) by the time the browser has to actually render we are good to go.
Yes you can do this. As long as something has been "injected" into the DOM (whether as part of the original page load, or as a DOM manipulation, you can select it in a subsequent command.
btw, I gather we can have a path ID where each segment corresponds to a node higher in the hierarchy? So I could specify /body/left-leg/sock and /body/right-leg/sock and have the DOM wearing two different socks?
Yup. Jquery supports that particular subset of xpath (although with a slightly different syntax).