leonidas / transparency

Transparency is a semantic template engine for the browser. It maps JSON objects to DOM elements by id, class and data-bind attributes.
http://leonidas.github.com/transparency/
MIT License
969 stars 112 forks source link

Re-rendering works not correctly? #151

Open LiguidCool opened 8 years ago

LiguidCool commented 8 years ago

https://jsfiddle.net/es8behkn/4/ I want, load many JSON files, but I can't render them. What do I do wrong?

woubuc commented 8 years ago

When you call .render on an element, it goes back to its original state as defined in the HTML. Try wrapping them in separate elements, like so: https://jsfiddle.net/edu1gp3a/

Alternatively, you could first do all AJAX requests, and then combine the data in 1 object and render it all at once.

LiguidCool commented 8 years ago

Yep, that works. But if i use $('body').render(data); (or <html>? I want rerender whole html file ... May be wrappers can help, but wrappers in wrappers etc ... Not good.

LiguidCool commented 8 years ago

https://jsfiddle.net/8uau1qo7/1/ I can use async.js, but i think that also bad practice.