I’m developing project on rails 2.3.8 and I need to use observe_field in model dialog box but it didn’t work for me. Is it possible to use “observe_field” on model dialog box? Please can some one explain me how to use this on model dialog box ?
This how I use observe filed
<%= collection_select("event", "trainer_id", @trainers , :id, :name, {:prompt => true}) %>
<%= link_to_remote 'Show calendar', :url => {:controller => 'calendar', :action => 'dynamicTrainer'} %>
<%= observe_field 'event',
:url => {:controller => 'calendar', :action=> 'dynamicTr'},
:with => "'mypara=' + escape(value)" %>
This is dynamicTr method in calendar controller.
def dynamicTr
if (defined? (params[:trainer_id]))
session[:my123] = 'defined'
else
session[:my123] = 'not'
end
end
def dynamicTrainer
session[:mySerach]=params[:mypara]
@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[:mySerach].nil?
if (defined? (params[:mypara]))
session[:mySerach]=(params[:mypara])
#@@id=(params[:event][:trainer_id])
@event_strips = Event.event_strips_for_month(@shown_month, @first_day_of_week, :conditions=>["trainer_id = ?",session[:mySerach]])
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[:mySerach]])
end
end
And this is my dynamicTrainer.js.rjs file
page.replace_html 'show_cal', :partial => 'dynamicTr'
page<< "$j ('#show_cal_dialog').dialog({
title: 'calendar',
modal: true,
width: 500,
height: 500,
close: function(event, ui) { $j ('#show_cal_dialog').dialog('destroy') }
});"
This is dynamicTr partial code
<%= stylesheet_link_tag "event_calendar" %>
<%= event_calendar%>
<%= session[:my123]%>
problem is it shows the calendar but it doesn’t print the session values. Can’t I use observe_field on model dialog box ? Please can someone explain me the problem here.
I think there is a problem in your observe field.
use the id of collection_select field in observe field as ‘event_trainer_id’