Kadoudal
2006-Jul-26 17:55 UTC
[Rails] render :update do | page | to modify a css class string...
In my booking/_form.rhtml, I have 2 <input text fields> startingdate (selction from unobstrusive calendar ) and endingdate <div> <label for="startdate">Booking Start Date</label><br /> <%= text_field_tag(''startdate'', @startdate, {:class => @startdateclass, :readonly => "readonly", :maxlength => "25"} )%> <%= observe_field("startdate", :frequency => 0.5, :url => {:controller => ''booking'' , :action => ''startdateChanged'' }, :update => ''enddate'', :with => "''input=''+$(''startdate'').value ")%> </div> <div> <label for="enddate">Booking End Date</label><br /> <%= text_field_tag(''enddate'', @enddate, {:class => @enddateclass, :readonly => "readonly", :maxlength => "25"} ) %> </div> in my controller when a new startingdate is selected, I modify the endingdate field value (+10 days) but I should also modify the css clas that will toggle some dates in the calendar ( a format with rangelow..) but I don''t know how to modify the css class string of the ending date the value is correctly set, not the css class when rendering the page.... def startdateChanged pd = ParseDate::parsedate(@params["input"]) tl = Time.local(pd[0], pd[1], pd[2]) @enddate = (tl+(84600*10)).strftime("%d/%m/%Y") render :update do | page | page[''enddate''].value = @enddate @enddateclass = "format-d-m-y range-low-" + (tl +(84600*10)).strftime("%d-%m-%Y") end end thanks for your tricks kad