Saturday, 31 August 2013

JS in Rails App only loads the first time

JS in Rails App only loads the first time

I am using a fade effect on some links on my applications home page. This
is being accomplished by some JQuery:
javascripts/pages.js
$(document).ready(function() {
$('.home_tile_text').hide().removeClass('text').addClass('text-js');
$('.home_tile_overlay').hide().removeClass('overlay').addClass('overlay-js');
$('.home_tile').mouseenter(function(){
$(this).find('.text-js').finish().hide().fadeIn();
$(this).find('.overlay-js').finish().hide().fadeIn();
});
$('.home_tile').mouseleave(function(){
$(this).find('.text-js').finish().show().fadeOut();
$(this).find('.overlay-js').finish().show().fadeOut();
});
});
This all works great when I fire up the app for the first time. However,
if I navigate away from the home page, when I come back, the fade effect
no longer works until I "refresh" the page. Any ideas?

No comments:

Post a Comment