Domanda

I have observe_form in my view: <%= observe_form 'new_lead', :url => { :action => 'update_price' }, :frequency => 0.1 %> , _update_price.rjs partial and this method in controller:



      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

I'm upgrading rails_2 app to rails_3. On rails_2 it's no errors, but when I upgrade project to rails3 I have javascript error in 3484 line of prototype.js: "$(...).getElementsByTagName is not a function ".



       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;
        }
       );}, 

And 'update_price' does not calling periodically. I don't know is it problem related to rails upgrading or just problem with JS :( How can I fix this problem?

È stato utile?

Soluzione

Rails 3.1 uses jQuery instead of Prototypejs. You can get back the prototype functionality by using something like https://github.com/rails/prototype-rails

Related How to swap jquery for prototype in Rails 3.1

Altri suggerimenti

Than if somebody have an error:



    TypeError: document.on is not a function

Changing prototype.js 1.6.x to 1.7 will solve it ;)

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top