Ok, now that this works seems I'm still in trouble.
The page I'm loading is one that has a table that I'm trying to make
clickable and a form to enter more data.
Here is the controller:
@auth.requires_login()
def budget():
db.expense.parent_table.default = request.args(0)
db.expense.category.requires =
IS_IN_DB(db(db.categories.parent_table==request.args(0)),'categories.id','categories.name')
form = crud.create(db.expense)
expenses = db(db.expense.parent_table==request.args(0)).select()
return dict(user=auth.user.first_name, expenses=expenses, form=form)
def edit_expense():
return repr(request.vars.id)
My view:
<table>
<tr>
<th>Date and Time</th>
<th>Title</th>
<th>Category</th>
<th>Amount</th>
<th>Source</th>
</tr>
{{ for expense in expenses: }}
<tr class="expenses"
id="{{=expense.id}}"
onmouseover="jQuery(this).attr(style.backgroundColor='lightgrey')"
onmouseout="jQuery(this).attr(style.backgroundColor='white')"
>
<td>{{=expense.datetime}}</td>
<td>{{=expense.title}}</td>
<td>{{=expense.category.name}}</td>
<td>{{=expense.amount}} {{=expense.denomination}}</td>
<td>{{=expense.source}}</td>
</tr>
{{pass}}
</table>
<hr />
{{=form}}
<script>
$(document).ready(function () {
$('.expenses').click(function(){
ajax('edit_expense?id=' + $(this).attr('id'), [], '#target')
});
});
</script>
<div id="target"></div>
I added the AJAX script to have it return to edit_expense the id of the row
that was clicked but I get an error about the crud.create line in my
controller.
Thanks again for your help.
Tsvi