theironcook / Backbone.ModelBinder

Simple, flexible and powerful Model-View binding for Backbone.
1.42k stars 159 forks source link

Stupid question #213

Closed boussou closed 9 years ago

boussou commented 9 years ago

I am trying out ModelBinder for the first time. Looking at the sample code Example1.html, I am wondering why not taking the HTML directly from the body content? here is the code showing what I mean: http://plnkr.co/edit/ZxGK7A23Lq6d2fTdTZfF?p=catalogue

I mean, why having the same HMTL code wrapped in JS within render()??

boussou commented 9 years ago

I am talking about this sample code: https://github.com/theironcook/Backbone.ModelBinder/blob/master/examples/Example1.html

amakhrov commented 9 years ago

The way the template is fetched and rendered is actually outside the scope of ModelBinder. I believe it's inlined in JS code for the sake of better visibility. However, it makes absolutely no difference to how ModelBinder is used with the rendered view.

boussou commented 9 years ago

Obviously indeed. I like this piece of software ;-)

theironcook commented 9 years ago

@amakhrov is correct. The ModelBinder doesn't care where the html comes from - the example is small and simple just to show how things can work. Not necessarily best practices. HTML templates in my project are pre-compiled on the server via NodeJS and bundled as functions that are auto-injected into views based on namespace conventions. But the ModelBinder doesn't care how the views get their html.

boussou commented 9 years ago

Thanks. You lost me at "..that are auto-injected into views based on namespace conventions".

My idea was to use it in conjuction with traditional server rendered pages, or in conjunction with a pjax content.

But mainly just to be able to edit the HTML in a regular HTML editor like dreamweaver (so outside those annoying script tags)