Archive

Archive for the ‘Bug’ Category

Bug in Rails’ observe_field and prototype.js

March 8, 2007 1 comment

I tried using Rails’ observe_field yesterday, and it didn’t work if you specified the :frequency option with the value set to less than or equal to 0.

Code snippet:

<%= observe_field :item_id,
:frequency => 0,
:update => “this_part”,
:url => {:action => ‘new’},
:with => “‘item_id=’ + value” %>

You would have got a javascript error in prototype.js at

 onElementEvent: function() {
var value = this.getValue();
if (this.lastValue != value) {
this.callback(this.element, value);
this.lastValue = value;
}
}

It would seems that nothing was happening if you weren’t on the look out for javascript errors.  No big issue.  Just remove the :frequency option and you are good to go.  The frequency option works fine for values greater than 0.

My version of Rails: 1.2.2

Categories: Bug, Ruby on Rails