4 ms·
Hey Rich, this looks like it's a lot easier to get into than Angular or Backbone, as someone who doesn't have a lot of JS experience beyond jquery. However, I'm
by tstactplsignore 13y ago
Hey Rich, this looks like it's a lot easier to get into than Angular or Backbone, as someone who doesn't have a lot of JS experience beyond jquery. However, I'm interested in connecting it to a server.
I really like the classic "Hello, {name}" example- how would I go about supplementing that so not only is the model constantly updated on the client JS side, but also on the server's database? Is there some place where I put a .ajax() call and Ractive.js handles the rest? (So the functionality would then be to display the name in the database, but whenever modified by the user, the database's value is also modified)
- madlynormal 13y agoI'm also interested in hearing the recommended way to handle this situration.
- rich_harris 13y agoAt the moment, Ractive doesn't really have an opinion on the subject - it was initially developed with news interactives in mind, where very often there isn't a need to communicate to a backend. Backbone et al are better at handling that side of things. The Ractive approach is to use an 'adaptor' - so you could create a Backbone Model or Backbone Collection adaptor that maps to a particular 'keypath' (such as 'user' or 'items'), and whenever the model changes, Ractive updates. With two-way binding, user interactions can also change the model. This part of the library is underdeveloped and experimental at the moment, but that's the approach we'll most likely be taking. You can use Ractive on the server however - you can use the same data on the server as on the client and call ractive.renderHTML(), which is useful for progressive enhancement.