Rails 5/6: How to include JS functions with webpacker?

后端 未结 4 810
栀梦
栀梦 2020-12-05 19:50

I am trying to update a Rails 3 app to Rails 6 and I have problems with the now default webpacker since my Javascript functions are not accessible.

I get: Refe

4条回答
  •  無奈伤痛
    2020-12-05 20:07

    Replace the code in your custom java Script file from

    function function_name() {// body //}
    

    to

    window.function_name = function() {// body //}
    

提交回复
热议问题