Topic: RJS causing problems in IE


I've got 2 almost identical simple RJS files:

page["scenario_#{}"].replace :partial => 'scenario',
                                         :locals => {:scenario => @scenario,
                                                     :current_milestone => @current_milestone,
                                                     :users => @users}
page["scenario_#{}"].visual_effect :highlight
page["flash"].replace_html flash_div

In Opera and FF it works fine. But in IE everything works except replacing element with partial. The problem is that I don't get any JS errors. I get them later when trying to click elements on that part that should have been updated.

I've tried to replace element with a simple string, instead of a partial, but it doesn't work as well. And I can't use replace_html instead, because I'm replacing tr elements. Is it known issue?

BTW. My both rjs files are almost identical - is there a way to specify rjs file to execute in the action in respond_to format.js block, so I call the same rjs file for create and delete action?

Re: RJS causing problems in IE

Had exactly the same problem yesterday, "replace" doesn't work in IE, see here:
I haven't tried to apply the patch they suggest there yet.

Re: RJS causing problems in IE

Thanks! I'll try to apply the patch posted there.

EDIT: Seems to work, but only partially. I.e. when I'm creating an object, the row is replaced just fine. But if I want to remove it later, I get "RJS error - [Object error]" + lots of JS generated by RJS. If I create an object, reload the page, then removing it works just fine.

Last edited by g0nzo (2007-07-19 11:05:02)

Re: RJS causing problems in IE

I guess I know what's happening.

In my partial I've got 2 tr elements. In my RJS I remove one of them and then replace the other one with the partial, so I've got 2 tr elements again. At least in Opera and FF.

In IE (after applying the patch) it inserts only the first tr element from the partial.

Do you guys have any idea how to fix it?

I fixed it by separating partial into 2 partials.

I sucks because now I need to make a wrapper partial (I use :collection => @foo), so instead of one partial I've got 3 now. Now I've got 8 partials for a simple table that uses bunch of ajax - is it normal? smile And it turns out that I need to be able to update some other fields after Ajax calls as well, so I guess I'm gonna have at least 2 partials more.

Last edited by g0nzo (2007-07-20 04:28:33)