RJS - not working in IE

I searched thru all the postings about RJS, and I didn’t find one person
who complained of problems specific to IE, but that’s what I’ve got.

My environment is:

Rails 1.0 + RJS Plugin
Updated Javascripts to Scriptaculous 1.5.3 (for evalScripts support)
Monkeypatched in_place_editor to support evalScripts

I have just started using RJS, and I have two .rjs templates. They are
quite simple, each template has two page.replace_html statements, which
look like:

page.replace_html “some_id”, :partial => “some_partial”
page.replace_html “some_other_id”, :partial => “some_other_partial”

These rjs templates work fine in Safari on Mac, Firefox on Mac, Firefox
on Windows. But they fail to work on Internet Explorer on Windows.
They fail in exactly the same way. The first page.replace_html
statement works, but the second statement does not.

Ideas? Help? Please?


Lori O.
http://blog.dragonsharp.com

On 18 Mar 2006 00:24:38 -0000, Lori O.
[email protected] wrote:

quite simple, each template has two page.replace_html statements, which
Ideas? Help? Please?


Lori O.
http://blog.dragonsharp.com

The problem isn’t RJS necessarily, but the javascript it’s sending
back. Try using my RJS debugging responder to see exactly what JS is
being sent to IE:

http://rails.techno-weenie.net/tip/2005/12/20/debugging_your_rjs_calls


Rick O.
http://techno-weenie.net

On 18 Mar 2006 00:24:38 -0000, Lori O.
[email protected] wrote:

quite simple, each template has two page.replace_html statements, which
look like:

page.replace_html “some_id”, :partial => “some_partial”
page.replace_html “some_other_id”, :partial => “some_other_partial”

These rjs templates work fine in Safari on Mac, Firefox on Mac, Firefox
on Windows.

I’m curious, because I’m having trouble getting the eval to happen
automagically on either Safari or Firefox when using the exact same
type of rjs template that you are using (I have to do an :complete =>
“eval…” in my tag) - why you mention Scriptaculous and the
monkey_patch eval support? Were you already using Scriptaculous for
other purposes and just needed to merge this functionality in?

On Friday, March 17, 2006, at 6:40 PM, Rick O. wrote:

The problem isn’t RJS necessarily, but the javascript it’s sending
back. Try using my RJS debugging responder to see exactly what JS is
being sent to IE:

http://rails.techno-weenie.net/tip/2005/12/20/debugging_your_rjs_calls


Rick O.
http://techno-weenie.net

Thanks for the reply, Rick. I have actually used your debugging
responder, but I don’t see anything different (Javascript-wise) in IE
than what I see in Firefox. There are two Element.update calls that are
identical to what works in Firefox. In IE, the first one works and the
second one does not.

Just for laughs, I switched the two statements in the rjs file around.
That seems to confirm that IE has issues with second statement in both
files, because then nothing works.

In my first rjs file, I am replacing an in_place_edit_field, and then
div containing an

    .

    In my second rjs file, I am replacing an in_place_edit_field, and then a

  • .

    While looking at this second one today, I came to the realization that
    the

  • was a problem, and I needed to use page.replace, not
    page.replace_html. ( In fact, I knew that already,
    because I used to have a table there, not a list, and that would never
    work in IE, even with the page.replace). And bingo! that one works now.

    Back to the first rjs. Is it a problem that I am rendering a partial
    that then goes and renders another partial? Works in Firefox. This is
    the partial:

    
    

      <% if @current_search.conditions && @current_search.conditions.size > 0 %> <%= render :partial => 'condition', :collection => @current_search.conditions.sort { |b, a| a.id <=> b.id } %> <% else %>

       

       

       

      <% end %>


    Lori O.
    http://blog.dragonsharp.com

Lori,

Support for evaluating scripts in the in_place_editor was comitted to
the Rails trunk today in http://dev.rubyonrails.org/changeset/3985.
You can use it with the option :script => true.

RJS is a quickly moving target right now and I am too busy to add all
of the new changes. Rails 1.1 will be out soon and will include RJS.
Otherwise, if you need all the latest and greatest features you should
track edge Rails.

On 19 Mar 2006 23:37:38 -0000, Lori O.
[email protected] wrote:

page, so I have the “need to update 2 divs” problem that RJS solves.
I still couldn’t get the in_place_editor to do anything with
then I did my 1-liner monkey-patching on in_place_editor, (starting from
of banging my head against brick walls, but at least it works now. And


Posted with http://DevLists.com. Sign up and save your time!


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails


Cody F.
http://www.codyfauser.com

Cody F. wrote:

Lori,

Support for evaluating scripts in the in_place_editor was comitted to
the Rails trunk today in http://dev.rubyonrails.org/changeset/3985.
You can use it with the option :script => true.

RJS is a quickly moving target right now and I am too busy to add all
of the new changes. Rails 1.1 will be out soon and will include RJS.
Otherwise, if you need all the latest and greatest features you should
track edge Rails.


Cody F.
http://www.codyfauser.com

Thanks, Cody. It’s nice to know that bit made it into Edge Rails so
it’ll
be there in Rails 1.1.

I DO have in_place_editor script evaluation working using all my little
hacks in Rails 1.0 + RJS Plugin. And that is where I will be for the
foreseeable future, because we have a production system that I can’t
destablize, and there are several showstoppers in Edge Rails for us.

Meanwhile, back to the topic of the thread, still puzzled why this
simple two-liner RJS fails to work in IE on Windows:

page.replace_html ‘current_search_name_editor’, :partial =>
“search_name”
page.replace_html ‘search_pane’, :partial => “search”

And the _search.rhtml consists of:

    <% if @current_search.conditions && @current_search.conditions.size > 0 %> <%= render :partial => 'condition', :collection => @current_search.conditions.sort { |b, a| a.id <=> b.id } %> <% else %>

     

     

     

    <% end %>

This works flawlessly in Firefox on Windows. And Firefox and Safari on
Mac. Does NOT work in IE. The second page.replace_html just seems to
do nothing in IE.


Lori O.
http://blog.dragonsharp.com

On Sunday, March 19, 2006, at 4:55 PM, Jeremy H. wrote:

On 18 Mar 2006 00:24:38 -0000, Lori O.
[email protected] wrote:

My environment is:

Rails 1.0 + RJS Plugin
Updated Javascripts to Scriptaculous 1.5.3 (for evalScripts support)
Monkeypatched in_place_editor to support evalScripts

I’m curious, because I’m having trouble getting the eval to happen
automagically on either Safari or Firefox when using the exact same
type of rjs template that you are using (I have to do an :complete =>
“eval…” in my tag) - why you mention Scriptaculous and the
monkey_patch eval support? Were you already using Scriptaculous for
other purposes and just needed to merge this functionality in?

Ok. I am using in_place_edit_field to allow the user to change a field.
The field is also displayed as part of a list on another part of the
page, so I have the “need to update 2 divs” problem that RJS solves.

But if you use Rails 1.0 + RJS plugin like me, you don’t get the benefit
of all the Edge Rails stuff. One of those benefits is that Edge Rails
is using the Scriptaculous 1.5.3 release. So I specifically had to
download and add those updated javascript files to my Rails 1.0 app,
because I needed this new feature from 1.5.3:

“Enable in place editor to use RJS (implements a new evalScripts option
for the in place editor), #3490 [thx Richard L.]”

I still couldn’t get the in_place_editor to do anything with
evalScripts, so I actually read the patch description:

http://dev.rubyonrails.org/ticket/3490

And I discovered:

“Note that the in_place_editor javascript helper in rails would also
need updating for this to be used with it.”

So I checked, and afaics, this fix isn’t even in Edge Rails yet. So
then I did my 1-liner monkey-patching on in_place_editor, (starting from
the Rails 1.0 version), to add evalScripts support:

js_options[‘evalScripts’] = options[:eval_scripts] if
options[:eval_scripts]

And then use that in my in_place_edit_field:

<%= in_place_editor_field :product, :name, {}, {:eval_scripts => true }
%>

After all that, I finally got my rjs templates updating my
in_place_edit_fields. Painful, and it took me the better part of 2 days
of banging my head against brick walls, but at least it works now. And
I understand plugins and monkey-patching better too. It was whatcha
call a “learning experience”. :wink:

I think the RJS plugin should be updated to include all this, to save
others time I wasted. I’ll have to try to find time to contact the
keeper of RJS plugin.


Lori O.
http://blog.dragonsharp.com

Lori,

What does your main view look like? I looked through the thread, but
I didn’t see what types of elements ‘current_search_name_editor’ and
‘search_pane’ are.

On 3/20/06, Lori O. [email protected] wrote:

track edge Rails.
I DO have in_place_editor script evaluation working using all my little

<% else %>


Cody F.
http://www.codyfauser.com

Cody F. wrote:

Lori,

What does your main view look like? I looked through the thread, but
I didn’t see what types of elements ‘current_search_name_editor’ and
‘search_pane’ are.

Fragment from my main view (it’s big, this is the relevent part)

<%= render :partial => "search_name" %>

<%= start_form_tag( { :action=> “master” }, { :id =>“conditions_form” }
) %>

<%= render :partial => 'search' %>
...

And the one-liner _search_name.rhtml partial:

<%= in_place_editor_field :current_search, :name, {}, {:script => true }
%>

I’ve also got a problem with IE and RJS although I think it’s with IE.
(sorry it’s a bit off this thread)

I have three select boxes that cascade data. Select the first ->
populates
the second etc.

this works without any trouble in FF but in IE it does nothing. I know
it
finds the element though because there is a highlight effect and this
works,
but it will not populate the drop down list with the data.

I used the debugging method for rjs on Rails-Weenie which was good.
This
showed that the data was being sent to the browser.

I found, searching through the archives that in IE you can put the
select
box into a DIV and replace the innerHTML of the DIV instead of trying
to
work directly on the SELECT. OK worked well when I made a selection
from
the first box. The highlight stopped working but I could almost live
with
that. But then I lost the listener on the second box so that when I
selected from the second box there was no response at all.

I’m assuming that this is because the object that the observer was
attached
to was replaced with a new object and now the observer is listening to a
phantom object.

How can I get this to work? Is there a way to reconnect the observer to
the
new select box, or is there a way to get IE to behave like it should?

Cheers