Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » Better handling for Ajax Pages & Fragments? [RSS Feed]

#1 March 24, 2008 11:23:09

[EMAIL P.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Better handling for Ajax Pages & Fragments?


I had a similar problem here and I solved it by using a specific flag
for ajax queries + a context processor to mirror the value of the flag
in the template context.
In my base template I have a big {%if flag %} so all the logo, menus
and whatnot don't get rendered for ajax queries. But if you get the
same URL without the flag
you have the template content but also the top menus and stuff. I'm
not sure it's the most elegant solution but it's sure DRY. In some
cases I also used a type flag so
some search can be returned as either an html or a json list depending
GET flags. This is handled by a generic return_hml_or_json function
which looks into the request to determine the output format.

Hope that helps.
Philippe


On Mar 23, 4:45 pm, "Tane Piper" <>
wrote:
> Hey folks,
>
> I'm working on a new interface for my site at the moment, and I'm
> using the jQuery UI Tabs to create it.  Inside each tab, there is a
> section of HTML and with this, some links to other content (for
> example in a tab for issues, I have a create new issue link that loads
> a form).
>
> What I do is when a link is clicked within this tab, I want to load up
> the required form in the tab.  However I don't want to load the whole
> page, just the fragment of code from the view.
> The problem is at the moment, to achieve this and still keep the side
> usable for non-ajax users, I have to keep the {% extend %} at the top
> of the code fragment, and when I click the link in the Ajax view it
> loads the whole page, not just the form.
>
> To get round this, in a way that works (as I can't wrap the extend in
> an if statement), I have to do a check on request.is_ajax() in the
> view.py code, and then select which template to use - both templates
> are exactly the same, but without the {% extend %} at the top of one.
>
> What I am asking is, does anyone know a better way for me to manage
> this without being anti-DRY??
>
> --
> Tane Piper
> Blog -http://digitalspaghetti.me.uk> Skype: digitalspaghetti
> Wii: 4734 3486 7149 1830
>
> This email is: blogable ask first private
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en-~----------~----~----~----~------~----~------~--~---

Offline

  • Root
  • » Django
  • » Better handling for Ajax Pages & Fragments? [RSS Feed]

Board footer

Moderator control

Enjoy the 16th of December
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support