How to use observ_field in the dialog box of the jQuery model on rails 2.3.8?

I am developing a project on rails 2.3.8, and I need to use check_field in the model dialog box, but this did not work for me. Is it possible to use the "observed field" in the model dialog box? Can someone explain to me how to use this in the model dialog? This is how I use the observed file

<%= 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 the dynamicTr method in the 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 partial dynamicTr code.

 <%= stylesheet_link_tag "event_calendar" %> <%= event_calendar%> <%= session[:my123]%> 
Problem

is that it displays a calendar but does not display session values. Can't use the observation window in the model dialog? Please can someone explain the problem to me here.

+4
source share
1 answer

I think there is a problem in your field of view.

use the id of the collection_select field in the watch field as 'event_trainer_id'

 <%= observe_field 'event_trainer_id, :url => {:controller => 'calendar', :action=> 'dynamicTr'}, :with => "'mypara=' + escape(value)" %> 
+4
source

All Articles