[Rails 3.1] weird jQuery behavior when pre-compiling assets

I am using the jquery-ui-1.8.16.custom.min.js lib… to toggle my
sidebar-views

======

$(’.toggle-view li’).click(function () {
var text = $(this).children(‘p’);
if (text.is(’:hidden’)) {
text.slideDown(‘fast’);
$(this).children(‘h4’).addClass(‘active’);
} else {
text.slideUp(‘fast’);
$(this).children(‘h4’).removeClass(‘active’);
}
});

I have a strange behavior : without any pre-compilation ( rake
assets:clean ) it runs well… toggle is good
then I pre-compile locally my assets before deployment
running again in development … toggle doesn’t work anymore … it
slideDown and slideUp immediately

if I clear again the assets : rake assets:clean , then correct
toggle behavior is good again …

what could happen when I run : bundle exec rake
assets:precompile:all to make this happen ?

thanks for your feedback

On 9 January 2012 12:02, Erwin [email protected] wrote:

   } else {

running again in development … toggle doesn’t work anymore … it
slideDown and slideUp immediately

if I clear again the assets : rake assets:clean , then correct
toggle behavior is good again …

what could happen when I run : bundle exec rake
assets:precompile:all to make this happen ?

I wonder whether you have an error in the script that behaves
differently when compiled. First run with firebug in firefox with it
not compiled and see if there are any errors. Then repeat with it
compiled.

Colin

Use jquery-rails gem this will solve your issue and also maintain your
update related to jquery

Thanks & Regards
Ankit Varshney

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs