I just deployed a rails app to Heroku and have found that there is a single javascript function. The function, officerCheck()
lives in its own file officerCheck.js
. And is called by an initialization file init.js
with the line officerCheck
.
The function is below; the first output to the log doesn't even show up
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');
}
}
}
Here is a list of what I've investigated so far:
- All other javascript functions work (including those called by init.js)
- The function
officerCheck
does indeed work on my localhost and heroku is up do date with that machine. - The function
officerCheck
and its respective call is indeed loaded by the browser when I'm browsing the heroku-hosted site. (I can see both in my script tab in firebug). - The contents of the function still work if I cut and paste them into firebug. (Leading me to believe that heroku just doesn't like how I'm calling the function)
- Calling the function from firebug with
officerCheck();
does NOT work. - However loading the function in its entirety into firebug and calling it with
officerCheck();
DOES work.
I'm guessing that I'm pulling some sloppiness that Heroku just won't stand for. Any ideas thoughts or admonishments are welcome.