Greetings,
I have an application which contains a calendar as alternative index view for Courses (Project has_many Courses). There I have two arrows for navigating to the next/previous month, it works via AJAX. Now, that's my action for updating the calendar:
def update_calendar
@project = Project.find params[:id]
@date = Date.parse(params[:date]).beginning_of_month
@courses = @project.courses.all(:conditions => {:date => (@date - 1.month)..(@date + 1.month)})
respond_to do |format|
# format.html { redirect_to :action => 'index' }
format.js { render :partial => 'calendar', :locals => {:calendar_date => @date, :courses => @courses} }
end
end
The important part is format.js { ... }
. I thought it should just answer js/AJAX requests, but it doesn't. It renders the partial when I hit the URL http://localhost:3000/projects/1/update_calendar?date=2010-08-01 for example. I don't want that behaviour, I just want it to answer correctly when it's coming in via AJAX. Do I need to use request.xhr?
? And what is format.js { ... }
supposed to do than?
Best regards
Tobias