Is it possible to add the last record from a database table into the last row of a html table using jQuery?
Something like this:
$(".save-expense .btn").click ->
$('#expense_table').append( Expenses.last )
And indicate which fields to use.
Thanks!
The good news first: Yes it is possible 🙂
What you want is to send an ajax request to your server which returns with the last expenses information. So your javascript should look something like this.
application.js
And your controller needs to know how to respond to this request, so:
your_controller.rb
the template looks something like:
_last_record.js.erb
PS I’m not sure what you mean with "And indicate which fields to use".
I’m kind of in a hurry so dont trust the syntax (especially the javascript ;))
Hope this helps! will check on it tomorrow again, if you need more help.