mikeric / rivets

Lightweight and powerful data binding.
http://rivetsjs.com
MIT License
3.23k stars 310 forks source link

Updating Pre-generated Bindings from Server #145

Open kmarsh opened 11 years ago

kmarsh commented 11 years ago

I'm trying to share data binding definitions between node.js and the browser.

I'm parsing an HTML template with node.js via jsdom, then sending that HTML to the browser and trying to re-bind and update the data.

The server side works, but re-binding the same elements with different data on the client doesn't seem to update the HTML. New bindings with different elements does work though.

Has anyone done this before?

thehydroimpulse commented 11 years ago

While I haven't done this with rivets, I've done it using reactive and it works quite well. I'm using cheerio on the server (node.js) instead of jsdom.

This is part of a framework I'm working on: https://github.com/tower/server-view

felixlaumon commented 11 years ago

+1!

There is a somewhat related issue https://github.com/mikeric/rivets/issues/158. Apparently, one way to get around is to removing all the pre-rendered elements and then have Rivets to render everything again. This works but will cause a huge reflow and repaint. Honestly, I think this approach kind of defeats the purpose of pre-rendering elements from the server.

We are trying to reduce the "time-to-content" in our web app, by pre-rendering the HTML on the server side (as inspired by http://nerds.airbnb.com/weve-launched-our-first-nodejs-app-to-product). Since the web app mainly runs on mobile device, we would really like a solution to this without causing massive DOM updates.