How To Refresh A Table In Template Of Django
Solution 1:
Both acceptable but disadvantages of the second approach(pulling table from django as html ):
Carried data over network is much bigger
If u use something javascript based components in your table (maybe dojo based buttons etc.) they may cause some problems. I had a smilar issue in dojo and i found the solution in make dojo reparse the applied html. But life could not be easy everytime so first approach is better.
Solution 2:
If this is only place where you need an auto-refresh, your approach 2 should work along with setting a timer to do the auto-refresh. You can use the setInterval
function for the purpose:
// Refresh the Table every 5 secondssetInterval(function(){
$.ajax({
url: '{% url myview %}',
success: function(data) {
$('#the-div-that-should-be-refreshed').html(data);
}
});
}, 5000)
But if you are planning on developing a responsive webpage, where the whole UI needs to be kept updated, then I would suggest to use a full fledged framework like ember.js
Post a Comment for "How To Refresh A Table In Template Of Django"