jquery change function

this snippet which follows another code block under $(document).ready(function () { isn’t working, the previous block works, but not this one

if (e.listing_free_shipping.attr(‘checked’))
$("#listing_shipping_cost").toggle( “blind” );

Just a couple of notes. The likely reason you have not had any offers
of help with these questions is that it is absolutely nothing to do
with Ruby or Rails, except for the fact that if you are finding that
document ready works sometimes but not others then this is likely due
to the fact that document ready is not compatible with turbolinks (if
you are using that). Google will explain what to do about it.

The other point I would make is that javascript should not normally be
included in the page, it should be in separate assets files.


Commenting out turbolinks in my gemfile didn’t help Also, how do i move my javascript to separate assets files

  Commenting out turbolinks in my gemfile didn't help

Assuming that you also did bundle install then it is not that problem,
so it is likely just a problem with the javascript. You probably need
to research how to debug js. Start by sprinkling assert statements
through the code. But as I said debugging js is not what this list is

Also, how do i move
my javascript to separate assets files

Do you mean you don't know how to code js so that it resides in
separate files (which is not a ROR issue) or you specifically don't
know how to use the rails assets. If the latter then [1] should help.

Note that the fact that you have included the js in the web page is
not likely to be the cause of your problem, it should work there but
it is considered poor practice.


[1] http://guides.rubyonrails.org/asset_pipeline.html