Reputation: 530
I'm new to Rails and AJAX and am stuck at how I can update a Rails table from a Javascript function with AJAX.
Specifically, I am working on a planner and when I drop a draggable div (this represents an item in my database) onto a calendar, I'd like to change the 'start date' for that item. I can retrieve the correct date upon placement, I just don't know how to update the Rails table variable with this new date.
Normally, I would access it as: batch_ticket.start_date.
From what I've seen, I need to make a remote AJAX call to update this variable but I'm stuck on how to do this. Any push in the right direction would be fantastic. Thanks!
Upvotes: 3
Views: 206
Reputation: 6318
checkout the :remote => true option available for rails forms. also look into creating an *.js.erb file which will be rendered back to the browser and executed after the remote form is submitted.
Upvotes: 2