views:

77

answers:

1

I'm using jQuery to create an inline calendar with my Rails application. To respond to date selections jQuery calls a function in Javascript. In my application, I'm wanting to query the database with the date selected and then update data onscreen based upon the results from the query.

What is the best practice to call a method from the controller in Rails through Javascript and the best way to update this information on screen.

A: 

The best way is to use AJAX. You ask your controller for the details of the selected date and how them in your page.

jQuery has good support for AJAX. This article show a nice and complete example how to implement it. Furthermore SO has lots of information about jQuery, AJAX and Rails

Veger