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?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Rajat Saxena
  • 3,834
  • 5
  • 45
  • 63
  • hang on - that's JavaScript - you should edit your answer to make it clear that this is (I presume) a JS snippet included in your template. – scytale Jul 11 '12 at 18:47
  • @rajat could you please tell if you found the solution for this, as I am facing the same problem with context processors – D Dhaliwal Nov 26 '13 at 20:26

1 Answers1

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.

scytale
  • 12,346
  • 3
  • 32
  • 46