Django - load page fragments using Ajax/Ajah

I have a complex page where some parts of the page take more time to load. I was thinking about using AJAH approach and load fragments using jQuery after initial page is loaded. Then I realized that should be quite common problem. How about some something like {% includeajax "sometemplate.html" %}?

What this means is load "sometemplate.html" using AJAH/AJAX. Wouldn't that be cool tag? Any ideas?

I know how to implement this, it would be nice to have reusable tag like this. Do you know about some other simple way to achieve this?



I made a middleware and a template tag to do this:

{% delayed_block big_table %}
    Real content. It will be loaded by Javascript at document.ready event.
{% delayed_stub %}
    Stub content that is rendered immediately.
{% enddelayed_block %}

When the page is loaded, a piece of Javascript notices a special class and requests it from the server, makes a request with ?partial=big_table parameter. When big_table is in partial parameters, this block renders the real content. The middleware catches the output, extracts only this block and wraps it in JSON. Then the Javascript module puts it into the right place.

The project is called django-partial-page. The django part of it is an egg, and the Javascript module is in example/media/js/partial.js.

Need Your Help

creating a popupwindow from html, not a file

php javascript ajax

I have a php page that displays rows from a mysql db as a table. One of the fields contains HTML markup, and I would like to amke this row clickable and the html would open in a new popup window. ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.