单个 Javascript 函数在 Heroku 上不起作用

Single Javascript function not working in on Heroku

我刚刚向 Heroku 部署了一个 rails 应用程序,发现只有一个 javascript 函数。函数 officerCheck() 存在于它自己的文件 officerCheck.js 中。并由初始化文件 init.js 调用 officerCheck.

函数如下;日志的第一个输出甚至没有显示

function officerCheck(){
    console.log("officer check in");
    var change=0;
    $('#toggle-two-wrapper').on('change', function(){
        if(change===0){
        checking();
        }else{
            change=0;
        }
    });
    function checking(){
        var alert=0;
        var existingRoles=[];
        neededRoles=["President", "Secretary", "Treasurer"];
        $("select.officer_role").each(function(i,e){
            existingRoles[i]=$(e).val();
            console.log("existing Roles "+existingRoles[i]);
        });
        $(neededRoles).each(function(i,e){
            if($.inArray(e,existingRoles)==-1){
                alert=1;
                $('div#final-submission').prepend("<span class='warning' style='display:block'>"+e+" needed.</span>");
                $("span.warning").delay(9000).slideUp("medium");
            }
        });
        console.log("alert equals "+alert);
        if(alert==1){
            console.log("we're in");
            change=1;
            $('div.incorporation_submit #toggle-two').bootstrapToggle('off');
        }
    }
}

这是我目前调查过的列表:

我猜我是在草率一些 Heroku 不会支持的内容。欢迎任何想法想法或警告。

Rails Heroku 上的应用程序 运行 可能需要一些工作才能让资产管道为自定义脚本提供服务。

您可以将脚本移至 application.js 并检查它是否从那里运行。

如果您想将脚本保留在原处,请参阅 Rails javascript asset missing after precompile