Chris S
2008-May-13  05:22 UTC
[object Error] troubles. Hope this saves someone some hair-pulling.
The following function worked fine in FF but not in IE - I''d get an
object Error (though I''m still not quite sure why):
function updateCartTotalPrice(element_id) {
    total_price_td = $(''total_price_td'');
    total_price = getPrice(total_price_td);
    this_price = getPrice($(element_id));
    updated_price = total_price - this_price;
    updated_price = updated_price.toCurrency();
    total_price_td.update(updated_price);
}
I thought for about an hour the offending code was the last line
(the .update), because the total_price_td is inside of a table. I had
heard that ie doesn''t play nice with innerHTML. So I tried using
replace, and a couple other things but still no dice. Well, it turns
out the problem was actually the first line. I guess because
total_price_td is the id of an element, IE choked. I''m not sure why
though - could someone explain that? Anyway to fix it I declared
total_price_td with var like I should have in the first place. Hope
this helps someone save an hour (or 3) of frustration.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
Christophe Porteneuve
2008-May-13  06:28 UTC
Re: [object Error] troubles. Hope this saves someone some hair-pulling.
Chris S a écrit :> out the problem was actually the first line. I guess because > total_price_td is the id of an element, IE choked. I''m not sure why > though - could someone explain that? Anyway to fix it I declared > total_price_td with var like I should have in the first place. Hope > this helps someone save an hour (or 3) of frustration.FWIW, IE will use a large set of sources when resolving document.getElementById (which is at the heart of $()), and your assigning the result to a same-named global variable may indeed confuse him, although I find it a bit weird. At any rate, you should indeed always declare your local variables as… local, thanks to "var". Scope pollution can be a VERY nasty thing, for instance when function A loops over calls to function B which has a same-name-index loop in it ;-) -- Christophe Porteneuve aka TDD tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---