Hello!

I was not able to find this information in one place so I had to piece it 
together, so I thought I would share it here:

On page 94 in the Cookbook the "Designing modular applications" example has 
some mistakes and consequently the new item is not displayed automatically when 
using the create form.

The problem lies in this function:
def edit_item():
    def display_changed(data):
        response.ajax = 'web2py_component("%s","show_itemlist")' 
%URL('showitems')
    form = crud.update(db.mytable, request.args(0), onaccept=display_changed)
    return form

specifically the 3rd line needs to be changed to:
response.js = "web2py_component('%s', 'showitems')" %URL('default','list_items')

It should be 
 - 1: response.js instead of response.ajax
 - 2: the web2py_component has to target the showitems DIV (created by the LOAD 
helper on the index page)
 - 3: the URL has to point to the list_items view

Well this is just what worked for me after a few tries, it may not be 100% 
correct, I am still learning!

-- 



Reply via email to