我正在将Rails 5与ruby 2.4一起使用
当我单击link_to
标签时,在视图页面上用link_to
标签写的语句很少,它会将我重定向到下一页,但是不要更改URL,这对我来说很奇怪。我的查看页面。
<div class="container">
<%= render "shared/breadcrumb" %>
<%= render "shared/back_button" %>
<h2>Cader</h2>
<div id="data_conversion_request">
<div class="row">
<ul class="list-group">
<% if @job.nil? %>
<li class="list-group-item">
<%= link_to 'Check out job', cader_available_job_path, class: '', title: 'check in an available job', data: {toggle: 'tooltip'} %>
</li>
<% else %>
<li class="list-group-item">
<%= link_to 'Check in a job', cader_check_in_job_path(:job_id => @job.id), class: 'btn btn-link', title: 'checkin job', data: {toggle: 'tooltip'} %>
</li>
<li class="list-group-item">
<%= link_to 'Release a job', cader_release_job_path(:job_id => @job.id), class: 'btn btn-link', title: 'release job', data: {toggle: 'tooltip'} %>
</li>
<li class="list-group-item">
<!-- <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>-->
<%= button_tag 'Download files', class: "btn btn-link", onclick: "job_files(#{@job.id})", data: {toggle: 'modal', target: '#files'} %>
<%#= link_to 'Download files', cader_downloads_path(:job_id => @check_cader[0].job_id), class: '', title: '', data: {toggle: 'tooltip'} %>
</li>
<li class="list-group-item">
<%= button_tag 'History', class: "btn btn-link", onclick: "history(#{@job.id})", data: {toggle: 'modal', target: '#history'} %>
<%#= link_to 'History', cader_history_path(:job_id => @check_cader[0].job_id),class: '', title: 'Job History', data: {toggle: 'tooltip'} %>
</li>
<% end %>
</ul>
<div> System Tools</div>
<ul>
<!-- <li class="list-group-item">-->
<%#= link_to 'Customer profile', 'javascript:void(0)', class: '', title: '', data: {toggle: 'tooltip'} %>
<!-- </li>-->
<!-- <li class="list-group-item">-->
<%#= link_to 'Messages', 'javascript:void(0)', class: '', title: '', data: {toggle: 'tooltip'} %>
<!-- </li>-->
<!-- <li class="list-group-item">-->
<%#= link_to 'Queue Status', 'javascript:void(0)', class: '', title: '', data: {toggle: 'tooltip'} %>
<!-- </li>-->
<li class="list-group-item">
<%= link_to 'Job folder', cader_job_folder_path, class: '', title: '', data: {toggle: 'tooltip'} %>
</li>
<!-- <li class="list-group-item">-->
<%#= link_to 'Reset timer', 'javascript:void(0)', class: '', title: '', data: {toggle: 'tooltip'} %>
<!-- </li>-->
<!-- <li class="list-group-item">-->
<%#= link_to 'Recent Jobs', 'javascript:void(0)', class: '', title: '', data: {toggle: 'tooltip'} %>
<!-- </li>-->
</ul>
</div>
</div>
<div id="checklist_data_conversion" style="display: none;"></div>
</div>
<!-- Modal -->
<div id="files" class="modal fade" role="dialog">
</div>
<!-- Modal 2 -->
<div id="history" class="modal fade" role="dialog">
</div>
<script type="text/javascript">
<% unless @job.nil? %>
function history(id) {
// console.log('Reached');
$.ajax({
type: "GET",
url: "<%= cader_history_path(:job_id => @job.id) %>",
data: {"id": id},
dataType: 'html',
success: function (data) {
$('#history').html(data);
// console.log('success');
},
});
}
function job_files(id) {
// console.log('Reached');
$.ajax({
type: "GET",
url: "<%= cader_downloads_path(:job_id => @job.id) %>",
data: {"id": id},
dataType: 'html',
success: function (data) {
$('#files').html(data);
// console.log('success');
},
});
}
<% end %>
</script>
但是相同的link_to
标记对于应用程序中的其余页面都可以正常工作,如果页面内的书写不正确或者还有其他方法可以写入link_to
标记,请更正。