When I try to access my action via myapp/statusbar/userEdit I see the
form as expected. However, when I try it at myapp/statusbar/
userEdit.json I get a "JSON serialization error".

This is my controller:

def user_widget():
    # return table of all users incl. their roles
    output = T('No users found')

    rows = db().select(db.auth_user.id, db.auth_user.username,
db.auth_membership.id, db.auth_membership.group_id,
left=db.auth_membership.on(db.auth_membership.user_id==db.auth_user.id))
    if len(rows) > 0:
        table_rows = []
        for row in rows:
            table_rows.append([row.auth_user.username,
row.auth_membership.id, row.auth_membership.group_id, A(T('edit'),
_href='#', _id='edit-user-' + str(row.auth_user.id), _class='edit-
user')])
        output = TABLE(THEAD(TR(TH(T('Username')), TH(T('Membership
ID')), TH(T('Group ID')), TH(T('Edit')))), *[TR(*myrows) for myrows in
table_rows], _id='user-widget-users-table')
        script = SCRIPT('$(function() { \
                            $("#user-widget-users-table a.edit-
user").click(function() { \
                                jQuery.ajax({ \
                                    type: "POST", \
                                    url: "'+
URL(r=request,c='statusbar',f='userEdit') +'", \
                                    data: "id=" +  $(this).attr("id"),
\
                                    success: function(msg){ \
                                        $("#settings-
content").html(msg.html); \
                                        $("#settings-
title").html(msg.title); \
                                    } \
                                }); \
                            }); \
                        });', _language='javascript')
        output.append(script)

    return {'html':str(output), 'title':T('User settings')}

def userEdit():
        # simplified - should return edit form a specific user later
        form=SQLFORM.factory(db.auth_user,db.auth_membership)
        return {'html':form, 'title':'test'}


The form contains two textfields and two selection fields and a submit
button. My statusbar/userEdit.json view ist the default one.

Any suggestions?

Reply via email to