You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Does Plates have the ability to modify the DOM directly (as opposed to parsing a template string)?
For example, let's say our <body> element contains the entire template. I could use jQuery and do something like
varhtml=$('body').html();//using jQueryvardata={"test": "New Value","etc":"foobar","add":"10 more data items here"};varoutput=Plates.bind(html,data);$('body').html(output);// useing jQuery, inefficient
but that replaces the entire contents of <body> (destroys the DOM the recreates a new one), which would be much less efficient than just modifying specific parts inside <body> where changes need to happen.
Does plates have a mechanim whereby it will crawl through the DOM and make changes only where needed?
It's inefficient to grab the body's html then replace it entirely with new html. It'd be more efficient for Plates to make the changes at the lower-most levels possible, right where the changes need to happen.
If Plates has no such mechanism, I'd like to make that my feature suggestion.
Such a feature would make Plates the best template engine ever (for JavaScript) in my humble opinion. :D
Perhaps the Plates.bind() method can also accept a dom element instead of a string. Usage might be like this:
vardata={"test": "New Value","etc":"foobar","add":"10 more data items here"};Plates.bind($('body')[0],data);// Here we pass a `domElement` to Plates.bind()
Alternatively, if Plates were to support jQuery, it'd be like this:
vardata={"test": "New Value","etc":"foobar","add":"10 more data items here"};/* * Here we pass a jQuery object to Plates.bind(). * Each element in the set of matched elements will be considered a template. */Plates.bind($('body'),data);
The text was updated successfully, but these errors were encountered:
I suppose I can write code in my web app to target specific lower-most elements then replace their HTML with the parsed result from Plates. I guess my feature suggestion would just be a safe guard against inefficient programming.
I'd second this feature request: I do a lot of evented (comet) applications, and I often find the need to update the DOM without replacing the actual elements. Many of the "hidden properties" (selection, focus, scrolling) et. al. are destroyed when the DOM is recreated, and so it is crucial that a large portion of the DOM is preserved.
Does Plates have the ability to modify the DOM directly (as opposed to parsing a template string)?
For example, let's say our
<body>
element contains the entire template. I could use jQuery and do something likebut that replaces the entire contents of
<body>
(destroys the DOM the recreates a new one), which would be much less efficient than just modifying specific parts inside<body>
where changes need to happen.Does plates have a mechanim whereby it will crawl through the DOM and make changes only where needed?
It's inefficient to grab the body's html then replace it entirely with new html. It'd be more efficient for Plates to make the changes at the lower-most levels possible, right where the changes need to happen.
If Plates has no such mechanism, I'd like to make that my feature suggestion.
Such a feature would make Plates the best template engine ever (for JavaScript) in my humble opinion. :D
Perhaps the Plates.bind() method can also accept a dom element instead of a string. Usage might be like this:
Alternatively, if Plates were to support jQuery, it'd be like this:
The text was updated successfully, but these errors were encountered: