0

I have a rails app deployed on heroku and am having some issues getting new javascript, written with jquery, working on the deployed version of the site.

I've tried many different ways to precompile the assets, and it appears they are actually precompiled when deployed to heroku. I don't however believe that precompiling is the issue. The strange thing is I can see the new Javascript functions loaded in the browser.

So for example I have one simple function that hides a button until another button is clicked, very simple and it works fine in development. On the deployed version of the site I am able to find that function in the application.js source file but the button it should be hiding is not hidden.

So it seems the javascript is loaded, but not working. Has anyone experienced this issue when deploying with Heroku?

Here is an example of some of the javascript that is not working, again written in jquery.

$('#remove_sock_selection').click(function(){
  $('#sock_images > ul > li > div').removeClass('selected').removeClass('make-thumbnail').removeClass('make-selected');
  $('#sock_images > ul > li').removeClass('mx-0');
  $('#sock_images > ul').removeClass('make-centered');
  $('#sock_images').addClass('mt-5');

  $('#sock_image_selected').hide();
  $('#packaging_images').hide();
  $('#addAdditionalSock').show();
});

it's really just adding/ removing css classes based on when things are clicked.

1 Answer 1

1

Do you already reset the cache or reboot your production? could you send the js you added? Just double check your production system if already been reboot/reset cache of you rails. It is a common issue when a js file updated in the production.

or maybe try reset your browser cache. Hope this will help.

Sign up to request clarification or add additional context in comments.

2 Comments

I just updated the question with sample js code. It's definitely not the browser cache I tried clearing that as well as using different computers. However how would I clear the cache on the production system? Is there a heroku command for that, I don't have any specific cache setup so it would be whatever is the default,.
have you already check the name of the button? also, you already include the javascript in the file where the js will be trigger? because sometimes maybe your development system is fully sync/clean while in production some of the file may differ.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.