我的视图中有observe_form:<%= observe_form 'new_lead', :url => { :action => 'update_price' }, :frequency => 0.1 %>
、_update_price.rjs partial和控制器中的这个方法:
def update_price
unless request.xhr?
redirect_to :controller => 'index'
else
set_price_group
render :partial => "update_price",
:locals => { :services => params[:service],
:spectr => params[:spectr] }
end
end
我正在将rails_2应用程序升级到rails_3。在rails_2上没有错误,但是当我将项目升级到rails3时,我在prototype.js的3484行遇到了javascript错误:"$(...).getElementsByTagName不是一个函数“。
getElements: function(form) {
return $A($(form).getElementsByTagName('*')).inject([],
function(elements, child) {
if (Form.Element.Serializers[child.tagName.toLowerCase()])
elements.push(Element.extend(child));
return elements;
}
);},
并且'update_price‘不会定期调用。我不知道这是与rails升级有关的问题,还是仅仅是JS的问题:(我如何解决这个问题?
发布于 2013-03-28 15:37:14
Rails3.1使用jQuery而不是Prototypejs。您可以使用诸如https://github.com/rails/prototype-rails之类的命令来恢复原型功能
发布于 2013-03-28 22:43:50
而不是有人犯了错误:
TypeError: document.on is not a function
将prototype.js 1.6.x改为1.7即可解决此问题;)
https://stackoverflow.com/questions/15670960
复制相似问题