I thought I had solved but I haven't.
Re: That means a whole different page is requested by the browser.
I get your point, you are saying when clicking a link even though the
script and navigation are in base.html it is still loading a new
instance of base.html and therefore can't keep state for jquery...
jquery only wokrs when page is in static and not navigated away
from... makes sense...

how do I store state across pages then to achieve this? save to JSON?

using seperate block nav for evey page seems like a lot of
duplication...

On Jul 15, 3:52 pm, David De La Harpe Golden
<david.delaharpe.gol...@ichec.ie> wrote:
> On 15/07/10 15:19, justin jools wrote:
>
> >    <script type="text/javascript" charset="utf-8">
> >            $(document).ready(function() {
> >                            $('#nav li a').click(function() {
> >                                      $('.active').removeClass('active');
> >                                      $(this).addClass('active');
> >                            });
> >            });
> >    </script>
>
> Okay hold on here, I'm obviously too used to there being some ajaxy hook
> on clicked links - you are just toggling a class there, clicking such a
> link will still navigate away immediately to an entirely different page
> since you haven't actually prevented the default action in that event
> handler.
>
> That means a whole different page is requested by the browser.
> Django is on the server side.  Once it's spat out the generated page
> (rendered from the template) to the client (browser), it doesn't have
> further involvement until the next time the client requests something
> from the server.
>
> If you haven't taken some sort of steps to arrange for a different link
> in your nav bar to _start out_ as active on that different page, then it
> will be whatever it is set to in your first template.
>
> If you want a different link to _start out_ with class "active" in
> different pages, you can do that in the templates.
>
> e.g. (one of several ways to do it, not necessarily the neatest):
>
> parent:
>
> {% block nav %}
> <ul id="nav">
>   <li class="home">
>     <a class="{%ifequal nav_current 'home' %}active{% endifequal %}"
>        href="/home/">
>          <span>Home</span>
>     </a>
>   </li>
>   <li class="about">
>     <a class="{%ifequal nav_current 'about' %}active{% endifequal %}"
>        href="/about/">
>          <span>About</span>
>     </a>
>   </li>
>
> ...
> {% endblock nav %}
>
> child:
>
> {% block nav %}
> {% with 'about' as nav_current %}
> {{block.super}}
> {% endwith %}
> {% endblock nav %}

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to