For the crossfade, you need to fully position your new content and with the same x / y coordinates as the old content. Here is an example:
page.insert_html :after, 'old-content', content_tag('p', '[new content]', :id => 'new-content', :style => 'display:none')
page << <<-JS
var oldOffset = $('old-content').cumulativeOffset();
$('new-content').setStyle({
position: 'absolute',
left: oldOffset.left + 'px',
top: oldOffset.top + 'px'
});
JS
page['old-content'].fade :duration => 3
page['new-content'].appear :duration => 3
Pay attention to the large block in the middle - some things are easier in the prototype than in RJS.
source
share