Ajax.Updater and observe_field disappearance in partial form override

5 views
Skip to first unread message

Giorgio Gonnella

unread,
Apr 24, 2008, 9:27:37 AM4/24/08
to ActiveScaffold : Ruby on Rails plugin
I am trying to add some javascript in form overrides (tried both via
partial and helper) either manually <script... or via "javascript_tag"
or fancier helper methods such as "observe_field" or
"text_field_with_autocomplete".

In all cases when I look at the page source everything else is there
but the script tag and all its content is not rendered.

I am sure it has to do with Ajax.Updater http://prototypejs.org/api/ajax/updater
evaluing my javascripts, but I wonder how to debug it.

(The things that I am trying to do are two, one is a double select
box, with the second loaded via ajax, the second is a simple
autocomplete text field - but it doesn't matter, any js code
disappears - for all the rest AS functions well)

This is an example of the double select box that does not work:

<%
indicator_classes = IndicatorClass.find(:all)
indicators_div_id = "ajax_indicators_loader_#{params[:eid] ||
params[:id]}"
indicator_classes_id = "indicators_classes_#{params[:eid] ||
params[:id]}"
%>

<li class="form-element"><dl>

<dt>
<label for="record_indicator">Indicator</label>
</dt>

<dd>
<%=collection_select(:record, :indicator_class_id,
indicator_classes, :id, :label, {}, :id => indicator_classes_id)%>
<div id="<%=indicators_div_id%>"></div>
<%= observe_field(indicator_classes_id,
:frequency => 0,
:update =>
indicators_div_id,
:url => { :action
=> :indicators_select_box},
:with =>
'indicator_class')%>

<%= render :partial => "test"%>

</dd>

</dl></li>

I have an action indicators_select_box in the scaffold controller.


Reply all
Reply to author
Forward
0 new messages