0

I created a custom context processor which returns "unread_messages_count".Now when I'm updating it on the template using:

var update_message_count = setInterval(function(){
                        $('a#check_messages').text('{{ unread_messages_count }}');
                        console.log('{{ unread_messages_count }}');
                    },1000);

I'm not getting update count of unread messages.But when I reload the page manually, I get updated count. So, I guess that "unread_messages_count" doesn't refresh on it's own. Right?

4

1 回答 1

4

The value {{ unread_message_count }} in your javascript is calculated at template render time and will be a hardcoded value in your page's JS (view the page source to see it).

Your question is quite unclear but it seems like you want that value to be updated dynamically. You would use an AJAX call to do this.

于 2012-07-11T18:50:09.487 回答