Forum: Ruby on Rails Works with iframe, but not ajax... ?!?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Randy M. (Guest)
on 2006-01-29 05:19
Hello all,

I've run into trouble attempting to replicate something in ajax that
worked when done with an iframe...

In both cases I have a table inside a div that is being periodically
refreshed every few seconds... The 1st column of each row in the table
contains a link to a DHTML popup menu. I have the popup menu working in
the ajax version.

The problem is that in the ajax version the popup menu disappears with
the next ajax call... Curiously, however, with the iframe implementation
of the table refresh, the popup menu layer persists through subsequent
refreshes until, as it is set up to do, the div's visibility is reset to
"hidden" by an onmouseout event.

As the persistence/disappearance of the menu layer would seem to be a
DOM thing, I don't understand why this behavior differs between the two
techniques.

As it's quite important that the menu not disappear until the user has
made a choice, I could just go back to the iframe approach, but I'd like
to stay with ajax...

Any wisdom on this would be much appreciated!

Thanks.
Randy M. (Guest)
on 2006-01-29 23:09
randy marmer wrote:
> Hello all,
>
> I've run into trouble attempting to replicate something in ajax that
> worked when done with an iframe...
>
> In both cases I have a table inside a div that is being periodically
> refreshed every few seconds... The 1st column of each row in the table
> contains a link to a DHTML popup menu. I have the popup menu working in
> the ajax version.
>
> The problem is that in the ajax version the popup menu disappears with
> the next ajax call... Curiously, however, with the iframe implementation
> of the table refresh, the popup menu layer persists through subsequent
> refreshes until, as it is set up to do, the div's visibility is reset to
> "hidden" by an onmouseout event.
>
> As the persistence/disappearance of the menu layer would seem to be a
> DOM thing, I don't understand why this behavior differs between the two
> techniques.
>
> As it's quite important that the menu not disappear until the user has
> made a choice, I could just go back to the iframe approach, but I'd like
> to stay with ajax...
>
> Any wisdom on this would be much appreciated!
>
> Thanks.

Hello again,

This just in from our FWIW (For What It's Worth) Dept....

The problem I was having was due to the fact that I had the popup menu
div coded within the partial. I took it out & put it into the .rhtml
file that calls the partial & now it behaves properly, i.e., the popup
menu persists until the user does a mouseout - despite the continuing
refreshes on the table.

The lesson here is to keep the partials clean & not just toss things
(like script & style tags) in there jsut cause it seems convienient.
This kind of thing, sloopy though it may have been), was fairly (too?)
easy to get away with when coding PHP...

Hope this helps someone.
This topic is locked and can not be replied to.