Search code examples
javascriptruby-on-railsajaxinternet-explorerprototypejs

Remote form completing properly in Chrome and Firefox, but not IE


I'm using remote_form_for in Ruby on Rails to create a pop-up form that gets some information through AJAX when submitted and returns it to the current page. Everything works great in Firefox and Chrome, but not in IE9. The Ruby code looks something like this:

remote_form_for  :quiz_questions,
                 :url => auto_populate_quiz_questions_path(),
                 :update => "quiz_questions",
                 :html => { :id => "auto_pop_questions_form" },
                 :position => "after",
                 :complete => 'toggle_hidden("search_comp", false); update_existing_questions(); ' do |f| %>

This produces HTML and Javascript code that looks right to me, but doesn't work in IE. Here is the HTML and Javascript:

<form 
 action="/cms/quiz_questions/auto_populate" 
 id="auto_pop_questions_form" 
 method="post" 
 onsubmit="new Ajax.Updater(
   'quiz_questions', 
   '/cms/quiz_questions/auto_populate', 
   {
     asynchronous:true, 
     evalScripts:true, 
     insertion:'after', 
     onComplete:function(request){
       toggle_hidden(&quot;search_comp&quot;, false);
       update_existing_questions(); 
     }, 
     parameters:Form.serialize(this)
   }
 ); 
 return false;">

From what I can tell, the onComplete is never firing in IE9. Why would the onComplete fire off properly in Chrome and Firefox, but not in IE9?


Solution

  • The problem here was with the insertion, it only happened when the parameter "insertion" was there. The fix was to upgrade Prototype. I was using Prototype 1.6.0.1 and a simple upgrade to 1.6.0.2 fixed the issues. A more major upgrade would probably fix it fine as well.