admins: fix tooltip ineffect after ajax render partial

dev_hs
p31729568 6 years ago
parent 4daeda7e14
commit cd33cc275f

@ -19,6 +19,8 @@
$.fn.select2.defaults.set('theme', 'bootstrap4');
$.fn.select2.defaults.set('language', 'zh-CN');
Turbolinks.setProgressBarDelay(200);
$(document).on('turbolinks:load', function(){
$('[data-toggle="tooltip"]').tooltip();
$('[data-toggle="popover"]').popover();

@ -7,6 +7,8 @@ class Admins::BaseController < ApplicationController
before_action :require_login, :require_admin!
after_action :rebind_event_if_ajax_render_partial
private
def require_login
@ -21,4 +23,16 @@ class Admins::BaseController < ApplicationController
render_forbidden
end
# 触发after ajax render partial hooks执行一些因为局部刷新后失效的绑定事件
def rebind_event_if_ajax_render_partial
return if request.format.symbol != :js
return if response.content_type != 'text/javascript'
path = Rails.root.join('app/views/admins/shared/after_render_js_hook.js.erb')
return unless File.exists?(path)
append_js = ERB.new(File.open(path).read).result
response.body += append_js
end
end

@ -1,12 +1,12 @@
<table class="table table-hover daily-school-statistic-list-table">
<thead class="thead-light">
<tr>
<th width="18%" class="edu-txt-left">单位名称</th>
<th width="14%" class="text-left">单位名称</th>
<th width="10%"><%= sort_tag('教师总数', name: 'teacher_count', path: admins_daily_school_statistics_path) %></th>
<th width="10%"><%= sort_tag('学生总数', name: 'student_count', path: admins_daily_school_statistics_path) %></th>
<th width="10%"><%= sort_tag('教师总数', name: 'teacher_count', path: admins_daily_school_statistics_path) %></th>
<th width="10%"><%= sort_tag('学生总数', name: 'student_count', path: admins_daily_school_statistics_path) %></th>
<th width="10%"><%= sort_tag('课堂总数', name: 'course_count', path: admins_daily_school_statistics_path) %></th>
<th width="10%"><%= sort_tag('正在进行课堂数', name: 'active_course_count', path: admins_daily_school_statistics_path) %></th>
<th width="14%"><%= sort_tag('正在进行课堂数', name: 'active_course_count', path: admins_daily_school_statistics_path) %></th>
<th width="10%"><%= sort_tag('实训总数', name: 'shixun_count', path: admins_daily_school_statistics_path) %></th>
<th width="12%">
<%= sort_tag('实训评测总数', name: 'shixun_evaluate_count', path: admins_daily_school_statistics_path) %>
@ -14,17 +14,16 @@
</th>
<th width="10%"><%= sort_tag('实训作业总数', name: 'homework_count', path: admins_daily_school_statistics_path) %></th>
<th width="10%"><%= sort_tag('其它作业总数', name: 'other_homework_count', path: admins_daily_school_statistics_path) %></th>
<th width="14%"><%= sort_tag('动态时间', name: 'nearly_course_time', path: admins_daily_school_statistics_path) %></th>
<th width="13%"><%= sort_tag('动态时间', name: 'nearly_course_time', path: admins_daily_school_statistics_path) %></th>
</tr>
</thead>
<tbody>
<% if statistics.present? %>
<% statistics.each do |statistic| %>
<tr>
<td class="edu-txt-left">
<%= link_to '#' do %>
<%= overflow_hidden_span statistic[:name], width: '200px' %>
<% end %>
<td class="text-left">
<%= link_to statistic[:name], "/colleges/#{statistic[:id]}/statistics",
target: '_blank', data: { toggle: 'tooltip', title: '点击查看学校统计概况' } %>
</td>
<td><%= statistic[:teacher_count].to_i %></td>
<td><%= statistic[:student_count].to_i %></td>

@ -30,7 +30,8 @@
<% statistics.each do |statistic| %>
<tr>
<td class="text-left">
<%= link_to statistic.school_name, '' %>
<%= link_to statistic.school_name, "/colleges/#{statistic.school_id}/statistics",
target: '_blank', data: { toggle: 'tooltip', title: '点击查看学校统计概况' } %>
</td>
<td><%= statistic['total'] %></td>
<td><%= statistic['other_total'] %></td>

@ -35,7 +35,8 @@
<% statistics.each do |statistic| %>
<tr>
<td class="text-left">
<%= link_to statistic.school_name, '' %>
<%= link_to statistic.school_name, "/colleges/#{statistic.school_id}/statistics",
target: '_blank', data: { toggle: 'tooltip', title: '点击查看学校统计概况' } %>
</td>
<td><%= statistic.teacher_increase_count.to_i %></td>
<td><%= statistic.student_increase_count.to_i %></td>

@ -0,0 +1,3 @@
;
$('[data-toggle="tooltip"]').tooltip();
$('[data-toggle="popover"]').popover();
Loading…
Cancel
Save