Simon,

I wanted to thank you for the answer you posted.
As a casual user of web2py, I would have never figured this out
on my own, but your clear example showing db, controller and view
made it easy for me to understand and to implement.

It would be great if the experienced users of web2py would
contribute similar small examples. I believe that would be
one way to help make web2py more popular.

ps. I had to modify the following to get update to work:
    jQuery('.dog_name').editable("{{=URL('dogs', 
'upd_dog_name')}}",{                  
to:
    jQuery('.dog_name').editable("{{=URL('default', 
'upd_dog_name')}}",{                  

- Tom


On Wednesday, September 4, 2013 11:25:49 PM UTC-6, Simon Ashley wrote:
>
> Download jeditable, 
> Install in the static/js folder.
>
> Include in layout.html i.e.
>   <script src="{{=URL('static','js/jquery.jeditable.js')}}"></script>
>
>
> *Model*
> db.define_table('dogs',
>     Field('dog_name','string'))
>
>
> *Controller:*
> def populate():
>     db.dogs.truncate()
>     db.fleas.truncate()
>     db.dogs.insert(dog_name='dagwood')
>     db.dogs.insert(dog_name='daisy')
>         
> def dogs():
>     db.dogs.dog_name.represent = lambda value, row: DIV(value if value 
> else '-',_class='dog_name', _id=str(row.id)+'.dog_name')
>     g = SQLFORM.grid(db.dogs, searchable=False, csv=False, user_signature=
> False)
>     return dict(form = g)
>
>
> def upd_dog_name():
>     id,column = request.post_vars.id.split('.')
>     value = request.post_vars.value
>     db(db.dogs.id == id).update(**{column:value})
>     return value
>
>
> *View:*
> {{extend 'layout.html'}}
>
> <script>
> jQuery(document).ready(function(){
>     jQuery('.dog_name').editable("{{=URL('dogs', 'upd_dog_name')}}",{     
>               
>         tooltip: "Click to edit, enter to save",
>  indicator : 'updating',
>  });})
> </script>
>
>
> <div id='dogs'>
>     {{=form}}
> </div>
>
>
>
>

-- 

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

Reply via email to