English 中文(简体)
Load html without refresh
原标题:

Im unsure of how to approach this, should I have the html to be loaded hidden or load it from somewhere? I want to load a form in one page, and dynamic content on other pages.

The form can be saved to mongo db, and when the page loads should load the data into that form from mongo db.

Where does the html live for all the pages? I want to have a clean html5 document with lets say a content div. all content goes into that block.

Server running Django Im want to use backbone.js for the app

any help would be appreciated

问题回答

The initial page should include the basic layout of the application (header, content, sidebar, different placeholder for your views, etc.)

Then you load the application (usually with a controller) and render the different view that will replace the placeholders you had in your layout.

To render the views, I suggest to use a templating engine. With backbone.js there is already underscore.js on the page, so you can use the templating engine included (http://documentcloud.github.com/underscore/#template). You then have to load the template on the page. The easiest way is to create include a script element on the page with your template inside:

<script type="text/template" name="template1">
your template here...
</script>

And you can load it using this:

var template = _.template( jQuery("script[name=template1]").text() )

and execute with your data

var html = template(model)

You build your page with different backbone views using different template.

I hope that help!





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签