ok, i went with qQuery.getJSON.  here is how i did it and it works great.  
JSON trading is cool.  just for sharing:

under the default controller's function, i have a section where i implement 
the javascript/jQuery code via an onchange of a select input.  the select 
input is meant to prepopulate with some options and if the user chooses an 
option then it grabs the values via the jQuery.getJSON from a separate 
function (below) under default:

            #bos...template
            tTGroup = db.task_group
            tTTemplate = db.task_template
            jq_template = """jQuery.getJSON('%s/ajaxTemplate', { 
template_id: jQuery('#task_template').val() }).done(
function(t) { 
jQuery('#task_task').val(t.task); 
jQuery('#task_task_group_id').val(t.task_group_id); 
jQuery('#task_recurring').val(t.recurring); 
jQuery('#task_time_spent_required').prop('checked', t.time_spent_required); 
jQuery('#task_directive_notes').html(t.directive_notes); 
});
""" % ('/cs/default')
            qTemplate = db((tTTemplate.id>0) & 
(tTTemplate.task_group_id==tTGroup.id)).select(orderby=tTTemplate.task)
            s = SELECT(OPTION("", _value=""), _id='task_template', 
_class='generic-widget', _name='template_ID', _onchange=XML(jq_template))
            for t in qTemplate:
                s.append(OPTION("%s (%s)" % (t.task_template.task, 
t.task_group.task_group), _value="%i" % t.task_template.id))
            frm[0].insert(1, TR(TD(LABEL("Task Template:", 
_id='task_template__label'), _class='w2p_fl'), TD(s, _class='w2p_fw'), 
TD("Choosing will overwrite certain fields.", _class='w2p_fc'), 
_id='task_template__row'))
            #eos...template

under controller default:

def ajaxTemplate():
    id = int(request.vars.template_id)
    return response.json(db(tTTemplate.id==id).select().first())

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to