views:

37

answers:

0

Hi.

I have a menu which shows certain information such as message_count, notifcation_count from django, and also a user profile that makes use of a load of jquery ajax functions to get information when a user clicks a url reference.

one of these reference relates to a users messages that he can view in his profile, without being redirected from the page.

I am wondering what is the best way to update the message count if the user clicks on the view message.

so the scenario is, the user is in his profile, in his header menu he has 3 unread messages, then he clicks on one of the unread messages that executes a jquery get function, then when the jQuery function is executed I would like to update the unread message count.

MENU.html

<li id="logged-button" class="login-button"><b>{% ifequal my_messages 0 %}{% else %}<span class="message-count">{{ my_messages }}</span>{% endifequal %} account</b></li>
    <div id="logged-button-expanded">
        <ul>
            <li style="margin-bottom: 10px; padding-bottom:10px;border-bottom:1px solid #f2f2f2; width:100%;"><b>{{ user.get_full_name }}</b></li>
        <li>{% ifequal my_messages 0 %}{% else %}<span class="message-count">{{ my_messages }}</span>{% endifequal %} <a href="/profiles/{{ request.user }}/#/messages/inbox/">messages</a></li>
        <li><a href="/accounts/password/change/">change password</a></li>
        <li><a href="/accounts/logout/">log out</a></li>
        </ul>
    </div>

PROFILE.html jQuery address plugin

$('.clickme').address(function() {  
    return $(this).attr('href').replace(/^#/, '');  
});