Ajax fails in IE8

hi guys,

I am testing a new optional funtionality in my site with IE 8 after
success with Firefox 3.6.3, chrome and safari.

The new functionality basically sees a “sub category” drop down list
get generated in my form as soon as a “Category” value is selected
from the “Category” drop down list.

I have been using the standard rails api such as observe_field, and
collective_select.

Anyway, when I loaded up the webpage on IE8 and selected a value from
the “Category” drop down list, the form fails to show the subcategory
drop down list.

Ajax doesn’t seem to be working here in IE8.
I know that rails uses prototype.
I have read that prototype 1.6RC2 is fully compatible with IE 8
(http://www.prototypejs.org/2009/3/27/prototype-1-6-1-rc2-ie8-
compatibility-element-storage-and-bug-fixes) .
I downloaded it and reloaded the webpage . No difference.

  1. has anyone managed to get around the problem whereby ajax use in
    IE8 fails?
  2. has anyone got an alternative such as using observe_field/
    observe_form and calling the whole url (appended with the selected
    values at the time to load the other dynamic values (in this case,
    category id which is appended to the url which would then load the
    whole page with a bunch of sub category values ) )?

thanks

On 4 June 2010 13:58, ct9a [email protected] wrote:

collective_select.

Anyway, when I loaded up the webpage on IE8 and selected a value from
the “Category” drop down list, the form fails to show the subcategory
drop down list.

Ajax doesn’t seem to be working here in IE8.

Just a thought, have you checked that your html is valid by pasting
the complete page source into the w3c html validator? Differences
between browsers is often down to invalid html.

Colin

Hi, Colin,

Every page I make has to pass by W3C’s validation.

It’s a pity why IE8 doesn’t really support prototype and rails’ JS
helpers are made out of prototype…

Any more ideas guys?

Gordon

Hi,

As I have to guess your code, I can just share my experience with Ajax
and IE.

I recently had a similar problem with the Ajax :update=>’<#id>’ call.
I updated a

element which went perfect in Firefox, but not in IE.
After changing the

element into a

my code fired in IE as
well. So, you might check the HTML you’re using.

Jan

ok i will look into it soon and report back. Thank you!

Anyone else? I m sure you guys use Ajax in your rails apps.

hi there, Javinto,

I checked and my code swapped some

for

. Tested and still no
good
with IE8.

diff --git a/app/views/parts/_form.html.erb
b/app/views/parts/_form.html.erb
index c5cd780…eae7407 100644
— a/app/views/parts/_form.html.erb
+++ b/app/views/parts/_form.html.erb
@@ -16,13 +16,13 @@
<%= render :partial => ‘sub_categories/select’, :locals => {
:part =>
@part } %>

  • <%= observe_field :part_category_id, :url => { :action => :get_subcategories }, :update => :subcategory_div, :with => 'category' %>

    <%= image_tag('required_attribute.gif', :alt => "image for required

attribute") %>
diff --git a/app/views/parts/get_subcategories.erb
b/app/views/parts/get_subcategories.erb
index 9737bad…498001d 100644
— a/app/views/parts/get_subcategories.erb
+++ b/app/views/parts/get_subcategories.erb
<% if (!@sub_categories.nil? and @sub_categories.length > 0) %>
-


+


Sub category:

<%= collection_select(
:part,
{:include_blank => true}
)
%>
-
+

<% end %>

Any ideas?

hi, guys,

I solved the problem.

SOLUTION: Do not explicitly include references to the prototype js
framework.

WHAT I HAVE IN MY SOURCE CODE (ie.
“app/views/layouts/application.html.erb”):

—Extract end

WHY THE PROBLEM OCCURED IN MY SOURCE CODE:

  1. Reading
    http://www.51773.com/tools/api.rubyonrails.org/classes/ActionView/Helpers/JavaScriptHelper.html,
    rails includes the Rails includes the Prototype JavaScript
    framework. I
    suppose this is done by doing either the following in the head of the
    application ( in my case, “app/views/layouts/application.html.erb”).
    Here’s
    an extract from the link I pasted:

libraries instead of fetching all the functions anew on every request."

  1. I seemed to have repeatedly referenced prototype.js (ie via
    :defaults,
    and script=“javascript/text” )

HOW I FIXED IT:

  • Removed all references to prototype.js and left the :default call in
    the
    javascript include tag (ie. " <%= javascript_include_tag :defaults,
    ‘jquery’ %>"
  • Restarted the web server and tested changes on firefox 3.6.3, chrome,
    safari, IE 7 and IE 8 - worked as expected.

Hope this helps some of you using IE 8.

Gordon Y.