Observer not working for checkbox

Hi,

My code is like this: <%= check_box_tag("criteria[#{count}][data_auto_complete]", "1",true) %>Private

<%= observe_field("criteria[#{count}][data_auto_complete]",                           :url => { :action => :choose_auto_complete_selection, :type_id => type_id, :count => count, :report_key => report_key, :rcolumn => rcolumn, :data_elem => @data_elem },                           :before => "Element.show('indicator_choose_select_all_#{count}')",                           :success => "Element.hide('indicator_choose_select_all_#{count}'); document.getElementById('_commit').disabled =false;",                           :with => "'value='+value") %>

But the observer is not firing when i change the state of the check box.

Another thing is that this code is coming in a partial that is rendered in a window created using extjs new Window.

Any suggestions why the observer wont work but the onclick event works.

It may be redundant, but you might try adding: :on=>'click' :frequency=>0.25

onClick is supposed to be the default for check boxes but it won't hurt to make it explicit. If that doesn't help, setting the frequency will make the detection time-based rather than event-based and help make sure the change in value is detected.

Still it didn't work... AndyV wrote:

Have you checked the rendered HTML to see if it looks to be correct and the id's are matching up the way you expect? If those are matching then my guess would be that the js itself has an error. Check it in FF w/Firebug.

AndyV wrote:

Have you checked the rendered HTML to see if it looks to be correct and the id's are matching up the way you expect? If those are matching then my guess would be that the js itself has an error. Check it in FF w/Firebug.

On May 16, 12:14 pm, Neha Chopra <rails-mailing-l...@andreas-s.net>

Here is the javascript that is getting generated: <input type="checkbox" value="1" name="criteria[1][data_auto_complete]" id="criteria[1][data_auto_complete]" checked="checked"/> <script type="text/javascript"> // 1 2//<![CDATA[ 3new Form.Element.Observer('criteria[1][data_auto_complete]', 0.05, function(element, value) {Element.show('indicator_choose_select_all_1'); new Ajax.Request('/reporting/choose_auto_complete_selection?count=1&report_key=jAb8wnDT&type_id=-2', {asynchronous:true, evalScripts:true, onSuccess:function(request){Element.hide('indicator_choose_select_all_1'); document.getElementById('_commit').disabled =false;}, parameters:'value='+value})}, 'click') 4//]]> 5 </script>