我知道由于资产管道编译问题等原因,有一些关于 Javascript 在 Heroku 中无法工作的问题......这超出了我的想象。
我只是想在我用 Middleman 构建的简单应用程序中添加一个简单的链接(见下文),它应该重新加载页面 onclick 并反过来触发 shuffle!方法:
<a href="javascript:;" onClick="window.location.reload()">Click to refresh</a>
这甚至可能吗?它在本地运行良好,但当我推送到 Heroku 时不再运行。任何想法/帮助表示感谢。
这是 Heroku 上实际应用程序的链接:http: //coastguard-quiz.herokuapp.com/
我的 index.html.erb 代码如下:
---
title: Coast Guard Quiz
---
<h1>Coast Guard Rank Quiz</h1>
<h3>Guess the enlisted insignia below:</h3>
<%
seaman_recruit = {
img: "<img src = 'images/USCG_SR.png'>",
name: "Seaman Recruit",
en_class: "Seaman",
}
seaman_apprentice = {
img: "<img src = 'images/USCG_SA.png'>",
name: "Seaman Apprentice",
en_class: "Seaman",
}
seaman = {
img: "<img src = 'images/USCG_SM.png'>",
name: "Seaman",
en_class: "Seaman",
abbr: "SN",
title:"Seaman (last name)",
paygrade: "E3"
}
ranks = [seaman_recruit, seaman_apprentice, seaman, pettyofficer3, pettyofficer2, pettyofficer1]
current_rank = ranks.shuffle!.first
img_now = current_rank[:img]
name_now = current_rank[:name]
class_now = current_rank[:en_class]
abbr_now = current_rank[:abbr]
title_now = current_rank[:title]
paygrade_now = current_rank[:paygrade]
%>
<div id="container" class="shadow">
<p><%= img_now %></p>
<div id="hideaway" style="display:none;">
<p class="bld"><%= name_now %></p>
<p><%= class_now %></p>
<p><%= abbr_now %></p>
<p><%= title_now %></p>
<p><%= paygrade_now %></p>
<a href="javascript:;" onClick="document.getElementById('hideaway').style.display='none'; document.getElementById('showme').style.display='block'">Hide Answer</a>
</div>
<div id="showme">
<a class="show" href="javascript:;" onClick="document.getElementById('hideaway').style.display='block'; document.getElementById('showme').style.display='none';">Get answer</a>
</div>
</div>
<a href="javascript:;" onClick="window.location.reload()">Click to refresh</a>