I am wondering if I answered my own (incomprehensible) question:

I plugged in Jeditable <http://www.appelsiini.net/projects/jeditable>, 
which is great.  Then I set the script up to post to a controller that 
inputs the data to the db (which validates, i.e., 'integer'), commits it, 
and then returns the value.  This seems safe & secure, but Im game if you 
guys disagree!  


########MODELS##########
db.define_table('dogs',
Field('dog_name','integer'))


########CONTROLLERS##########
def dogs():
    xml_string = []
    return locals()

def upd_dog_name():
    #id,column = request.post_vars.id.split('.')
    #value = request.post_vars.value
    x = request.post_vars['id']
    y = request.post_vars['value']
    db.dogs[x]={'dog_name':y}
    db.commit()

    return y

########VIEWS##########
<script src={{=URL('static','js/jquery.jeditable.js')}}></script>


<script>
jQuery(document).ready(function(){
    jQuery('.edit').editable('default/upd_dog_name',{       
    tooltip: "Click to edit, enter to save",
    indicator : 'updating',
     onblur: 'submit'});})
</script>
<div class="edit" id="1">Dolor</div>
<div class="edit_area" id="div_2">Lorem ipsum dolor sit amet, consectetuer
adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore
magna aliquam erat volutpat.</div>


On Tuesday, December 30, 2014 10:46:42 AM UTC-5, Mark Billion wrote:
>
> I may be an idiot but....
>
> I want to set up a form so that you click to edit, and on focus out, the 
> data is committed to the DB via Ajax. 
>
> 1.  Im using the inplace_edit(f,v) module from slices:
>
>     wrapper = DIV()
>     inp = SQLFORM.widgets.string.widget(f,v)
>     lbl = 
> SPAN(inp['_value'],_id='inplace_edit_'+inp['_id'],_style="cursor:pointer;")
>     scr1 = "jQuery('#%s').hide();" % inp['_id']
>     scr2 = "jQuery('#%s').bind('click',function(e){ 
> jQuery(this).hide();jQuery('#%s').show().focus();});" % \
>                          (lbl['_id'],inp['_id'])
>     scr3 = "jQuery('#%s').bind('blur',function(e){ 
> jQuery(this).hide();jQuery('#%s').show().text(jQuery(this).val());});" % \
>                          (inp['_id'],lbl['_id'])
>     jqscr = SCRIPT(scr1,scr2,scr3,_type="text/javascript")
>     wrapper.components.extend([inp,lbl,jqscr])
>     return wrapper
>
> 2.  My thought based on the book is that I need to add ['_onkeyup'] as an 
> attribute to the sqlform but this adds to the form itself.  
>
> ="ajax('{{=URL('default', 'echo')}}', ['name'], 'target')" 
>
> This failed horribly.
>
> Is there a slice/package/tutorial/something y'all can point me to?
>
>

-- 
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