You need a different url handler for each "tab" on the page.  So, your main
"schoolpage" will deliver the main html and script, but it's not yet
dynamic.

Then, when a user clicks tab 1, your getDataForContentPane1() should do an
ajax call to a *different url handler*, for example "class
schoolpage_pane1:"

The results will be sent to the browser, behind the scenes, via an
xmlhttprequest object.  (The page will not appear to refresh at all -
that's the whole point of ajax.)  Using purely javascript, you then take
the results of the response and write them into the proper place in the DOM.

This is pretty confusing in pure javascript in my opinion, and I'm not
familiar with the tab utility you're using.  I do know, however, that
jQuery makes ajax like this a lot easier.

Make sense?
S


On Mon, Dec 10, 2012 at 10:32 AM, Megha Vishwanath <
[email protected]> wrote:

> Hi All,
>
> I'm trying to set up a ajax based html page, with a tab view library (not
> jquery though, using barelyfitz.com's js/css that can be extended to
> Ajax).
>
> So this is the basic layout of my page:
> [image: Inline image 1]
>
> And my existing web.py method, calls on a class called schoolpage and
> writes to a template called school page.
>
> class schoolpage:
>    def get(id):
>       data = getAllData()
>       return render_plain.schoolpage(jsonpickle.encode(data))
>
> This worked fine while my tabs were superficial -i.e, no individual urls/
> ajax, just html-js-css voodoo.
>
> I'm now needed to call on a part of the data based on the tab clicked, so:
>
> class schoolpage:
>    def get(id,tab):
>       if tab == 1:
>          data = getDataForContentPane1()
>       if tab == 2:
>          data = getDataForContentPane2()
>       return render_plain.schoolpage(jsonpickle.encode(data))
>
> But I realised that if I do this, the template schoolpage is getting
> rendered within schoolpage.
>
> So I am wondering, how to design with webpy, html & js.
>
> Should I make the URLs and hence the classes and http request get calls
> completely distinct (and in that case who will call the holding / binding
> template with that some common data) or can the if condition render
> different templates within them? Since I don't write raw html in python,
> like I would in php, I'm having some trouble understanding this.
>
> How would you solve for this?
>
> Really hope someone can point me to suggestions and help with this.
>
> Regards,
> Megha
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "web.py" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/webpy?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/webpy?hl=en.

<<tab_view.png>>

Reply via email to