I am trying to display some data on a student and embed within it 2 ajax 
forms - one to add/edit/display contacts for the student, the other to 
add/display notes relating to them. I can get it working as a simple view 
but now want to display the ajax forms on different tabs. When I try to do 
this, the second form is shown in both places.

So far I have:
(Note I have hard coded the record id as '90' for demo purposes)

Controller:

*def index(): *
*    contacts_panel = LOAD('student',*
*                          'manage_contacts.html',*
*                          args=[90],*
*                          ajax=True)    *
*    notes_panel = LOAD('student',*
*                          'manage_notes.html',*
*                          args=[90],*
*                          ajax=True)*
*    return dict(contacts_panel=contacts_panel, notes_panel=notes_panel)*

*
*
*def manage_contacts():*
*    student_id = request.args(0) or redirect(URL('list_students'))*
*    db.relationship.student_id.default = int(student_id)*
*    db.relationship.student_id.writable = False*
*    db.relationship.student_id.readable = False*
*    db.relationship.adult_id.label = 'Contact Person'*
*    db.relationship.id.readable = False*
*    linked_contact = [lambda row: A('View 
Contact',_href=URL("adult","view_adult",args=[row.adult_id]))]*
*    form_contacts = SQLFORM.grid(db.relationship.student_id == student_id,*
*                        args=[student_id],*
*                        searchable=False,*
*                        editable=False,*
*                        deletable=True,*
*                        selectable=False,*
*                        details=False,*
*                        links=linked_contact,*
*                        csv=False)*
*    return form_contacts    *

*def manage_notes():*
*    student_id = int(request.args(0)) or redirect(URL('list_students'))*
*    db.student_notes.student.default=student_id*
*    db.student_notes.student.writable=False*
*    db.student_notes.student.readable=False*
*    db.student_notes.id.readable = False*
*    db.student_notes.created_on.readable = True*
*    db.student_notes.created_by.readable = True*
*    form_notes = SQLFORM.grid(db.student_notes.student == student_id,*
*                        args=[student_id],*
*                        searchable=False,*
*                        editable=False,*
*                        deletable=False,*
*                        selectable=False,*
*                        details=True,*
*                        csv=False)*
*    return form_notes     *

 
View:

* {{extend 'layout.html'}}*
*<h1>This is the test/index.html template</h1>*
*
*
*<!-- Tab 1 -- Basic 
-------------------------------------------------------------------->*
*    <div id="tab-1">*
*   Basic info goes here*
*    </div>**    *
*<!-- Tab 2 -- Contacts 
--------------------------------------------------------------->*
*    <div>*
*        {{=contacts_panel}}*
*    </div>*
*<!-- Tab 6 -- Notes 
------------------------------------------------------------------>*
*    <div>*
*        {{=notes_panel}}*
*    </div>**        *
*<!-- end of tabs -->*


The above works as expected, with contacts_panel and notes_panel 
independently updateable without refreshing the whole page.

*BUT* I need to display the above view as a jQuery tabbed form which 
requires giving the divs defining each tab an id. The view becomes:

* {{extend 'layout.html'}}*
*<h1>This is the test/index.html template</h1>*
*
*
*<!-- Tab 1 -- Basic 
-------------------------------------------------------------------->*
*    <div id="tab-1">*
*   Basic info goes here*
*    </div>**    *
*<!-- Tab 2 -- Contacts 
--------------------------------------------------------------->*
*    <div** id="tab-2"**>*
*        {{=contacts_panel}}*
*    </div>*
*<!-- Tab 6 -- Notes 
------------------------------------------------------------------>*
*    <div** id="tab-6"**>*
*        {{=notes_panel}}*
*    </div>**        *
*<!-- end of tabs -->*


This does not work. It initially displays OK, but adding a new record to 
the contacts_panel makes it display the notes_panel in its place when it 
refreshes. 

Any help would be much appreciated!

-- 



Reply via email to