What is the best practice for posting templates and database view code

I am creating an ASP.Net MVC 3 application using Backbone.js. I also use jQuery templates for views.

My question is how to organize files efficiently?

Currently, I have a XXX.js file for the base application and built-in templates stored on the page that shows the base application Index.cshtml. How to move templates to another file that I can include, for example, include XXX.js?

App/
  Scripts/
    backbone.js
    underscore.js
    jquery-1.6.4.js
    jquery.tmpl.js
    myBackboneApplication.js
  Views/
    Home/
      Index.cshtml
  Controllers/
    HomeController.cs

I would like to move the templates from Index.cshtml to something related to myBackboneApplication.js. Something that I can include as a file inside Index.cshtml instead of inlined.

+5
1

. :

  • Javascript .

  • HTML , , <script type="text/template">.

Backbone.js, - ant. (, my-view-template.html) <script> id="my-view-template", jQuery $("#my-view-template").html() .

+4

All Articles