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
matthew342 edited this page Jul 25, 2012
·
7 revisions
Backbone Integration
A good practice when using client-side frameworks such as Backbone.js or Ember.js is to pre-fetch JS models when serving the views from the server for the first time. This saves the initial HTTP request usually required to bootstrap the JS.
In order to pre-fetch JS models using RABL, one just need to render the relevant RABL template inline, within the view. For instance:
Create a partial for the object, this has to be named like app/views/foo/_bar.json.rabl. Note the leading underscore to indicate a partial. It is not mandatory. If you need to reuse the rabl template as a legacy view, discard the leading underscore.
In your HTML view:
where it is assumed the rabl template makes use of a @object variable.
This is not as clean as it could be, but this is 99% of the way there and it works.