Question

I am using django + jquery to write a html page, the layout of the page is:

head (divs)
--------------------------
left (divs) | right (divs)

I want to change the whole page (the head divs would be all the same, but the left and right divs would be changed) after I click the head divs(the js would send a post message to the django and get the responsed html).

now I could get the whole new page, but I don't know how to rerender the whole page again? any help would be appriciated!

Was it helpful?

Solution

You can do this with conjunction of jQuery load() and adding a new div to contain the content of the site:

head (divs)
--------------------------
container div
left (divs) | right (divs)
/container div

So you, do something like this.

$('#container').load('ajax/test.html #container');

See the documentation for jQuery load, it let's you loading into specific elements and filter which part of the html to include.

OTHER TIPS

Can't you simply use jQuery.load() ?

$('#left').load('ajax/test.html', function() {
  alert('Load was performed.');
});

There is much ways to do it:

  1. you click and django send via ajax the new content and the browser will display it
  2. you can keep the divs but change some of there content/text etc
  3. use the function load(), check here:enter link description here
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top