Yes, that is correct. I made the changes, (only minor adjustment to your solution was that I had to replace a 'default' with 'patient_scan_history' when setting response.js).
As usual, while writing my post I became slightly clearer in my head about where the problem lay, but didn't have the confidence to try anything until I heard back from this forum. During my searches, I found this helpful vimeo by 'mdipierro', which is related to your solution... http://vimeo.com/21363988 Thanks to all those who helped, I understand this a lot more now. Ann On Tuesday, 23 April 2013 22:08:22 UTC+1, Anthony wrote: > > If I understand correctly, the user must actually enter a patient id in a > form in the first component, correct? If that's the case, then you should > not use LOAD() for the third component, as LOAD() automatically loads the > component as soon as the parent page has loaded. Instead, you want to > trigger the third component to load after the user submits the patient id > in the first component. To do that, you can leave the div for the third > component empty: > > <div id="patient_scan_history" class="layout_block"></div> > > Then, in the patient_details() function, you can return some Javascript > that will trigger the third component to be loaded after the form has been > submitted: > > def patient_details(): > ... > if form.process().accepted: > ... > response.js = 'web2py_component("%s", "patient_scan_history");' %URL > ('default', 'patient_scan_history.load') > ... > return dict(...) > > When the form is submitted and the patient id has been saved to the > session, the patient_details() function adds some Javascript to > response.js, which will be executed in the browser when the Ajax call > completes. The Javascript calls the patient_scan_history() component and > loads its contents into the "patient_scan_history" div. > > Anthony > > On Tuesday, April 23, 2013 8:42:39 AM UTC-4, AnnG wrote: >> >> Hi, >> I have a main patient input page with 3 components on... >> >> <div id="content"> >> <div id="patient_info" class="layout_block"> >> {{=LOAD('patient', 'patient_details.load', ajax=True, >> target='patient_info')}} >> </div> >> <div id="phenotype_form" class="layout_block"> >> {{=LOAD('phenotype_form', 'phenotype_form.load', ajax=True, >> target='phenotype_form')}} >> </div> >> <div id="patient_scan_history" class="layout_block"> >> {{=LOAD('patient_scan_history', 'patient_scan_history.load', >> ajax=True, target='patient_scan_history')}} >> </div> >> </div>. >> >> ...and to work properly, 2 of those components (the first and third >> above) need a patient id, which is held in an input box (id="patient_id") >> on a form, in patient_details.load (first component above) ... >> >> <form id="patient_form"> >> <fieldset> >> <table> >> <tr> >> <td> Patient ID (or leave empty for new patient): <input >> name="patient_id" id="patient_id" value={{=(patient_id or '')}}></td> >> <td><input type="submit" value="Search Patient"></td> >> <div id="clearcanvas_target">{{=study_response}}</div> >> </tr> >> <tr> >> <td> Source: <input type='text' name='source' id='source' >> value={{=patient_source}}> >> Diagnosis: <input type='text' name='diagnosis' id= >> 'diagnosis' value={{=patient_diagnosis}}> >> </td> >> >> </tr> >> </table> >> </fieldset> >> </form> >> >> ... and here is the part of patient_load.py, where I can get the >> patient_id from request.vars.patient_id, and set a global variable >> session.patient_id to have the same value. >> >> if(request.vars.patient_id): >> session.patient_id = int(request.vars.patient_id) >> >> study_response = open_patient_images_clearcanvas(session. >> patient_id) >> >> db = get_db() >> >> rows = db((db.patient.patient_pk == db.patient_diagnosis. >> patient_fk) & (db.patient_diagnosis.diagnosis_fk == db.diagnosis. >> diagnosis_pk) & (db.patient.patient_pk == session.patient_id)).select(db. >> patient.source, db.diagnosis.diagnosis_name) >> >> ... >> >> >> The above patient_load component works OK. >> BUT the third component, where I wish to load patient history, and which >> also requires a patient_id, wont work properly, as the session.patient_id >> above is not updated until i press refresh. >> Here is my main patient_scan_history.py function >> >> def patient_scan_history(): >> patient_id = 1 >> if(session.patient_id): >> patient_id = session.patient_id >> db = get_db() >> patient_scans = Patient_scan_history(db, patient_id) >> patient_scan_history = patient_scans.get_patient_scan_history() >> else: >> return dict(html_table = None) >> >> html_table = TABLE( TR(*[TH(*headers) for headers inpatient_scan_history >> ['headers']]), *[TR(*rows) for rows in patient_scan_history['table']]) >> >> return dict(html_table=html_table) >> >> ... and my patient_scan_history.load >> >> <form> >> <fieldset> >> {{=html_table}} >> </fieldset> >> </form> >> >> So from the users point of view, the top component information loads as >> soon as there is a valid patient id and the submit ('search patient') >> button is pressed. But the third component is not updated at this point, >> and only shows the correct patient history table when the refresh button is >> clicked. >> >> As the 3rd component is reliant on a patient ID from the 1st component, >> I'm guessing maybe it should not be a component ?? >> Can anyone help??? >> >> Regards >> A >> >> -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.