I want to load a modal dialog box by clicking submit tag. but when I click on the button, it directly went to page without going to rjs file and did not render partial.
following is my code.
<span style="text-align: right">
<% form_tag "/calendar/dia_cal_view" do %>
<%= collection_select("event", "trainer_id", @trainers , :id, :name, {:prompt => true}) %>
<%= submit_tag "search" %>
<%end%>
</span>
controller code:
def dia_cal_view
@month = (params[:month] || (Time.zone || Time).now.month).to_i
@year = (params[:year] || (Time.zone || Time).now.year).to_i
@shown_month = Date.civil(@year, @month)
@trainers=Trainer.all
@first_day_of_week = 1
if session[:dia_Serach].nil?
if (defined? (params[:event][:trainer_id]))
session[:dia_Serach]=(params[:event][:trainer_id])
#@@id=(params[:event][:trainer_id])
@event_strips = Event.event_strips_for_month(@shown_month, @first_day_of_week, :conditions=>["trainer_id = ?",session[:dia_Serach]])
else
@event_strips = Event.event_strips_for_month(@shown_month, @first_day_of_week)
end
else
@event_strips = Event.event_strips_for_month(@shown_month, @first_day_of_week, :conditions=>["trainer_id = ?",session[:dia_Serach]])
end
end
dia_cal_view.js.rjs
page.replace_html 'search_result', :partial => 'cal_view'
page<< "$j ('#search_result_dialog').dialog({
title: 'calendar',
modal: true,
width: 500,
height: 500,
close: function(event, ui) { $j ('#search_result_dialog').dialog('destroy') }
});"
_cal_view.html.erb
<%= stylesheet_link_tag "event_calendar" %>
<%= event_calendar %>
The problem is that rjs file did not work. It did not go to rjs file. what should I do for this? plz help me..
first of all your form is submitted as a html and not as a rjs request.
You first need to change that to rjs request, change this line
use
or option
depending on your rails version
It should work then