Javascript 在不刷新页面的情况下重新加载charkick饼图
我的目标是,一旦提交删除操作,图表应在不刷新页面的情况下更新其值。这是我的代码: 在index.html.erb中:Javascript 在不刷新页面的情况下重新加载charkick饼图,javascript,jquery,ruby-on-rails,Javascript,Jquery,Ruby On Rails,我的目标是,一旦提交删除操作,图表应在不刷新页面的情况下更新其值。这是我的代码: 在index.html.erb中: <div class="chart" style="float: right; width: 500px" > <%= javascript_include_tag "//www.google.com/jsapi", "chartkick" %> <%= pie_chart current_user.events.group(:a
<div class="chart" style="float: right; width: 500px" >
<%= javascript_include_tag "//www.google.com/jsapi", "chartkick" %>
<%= pie_chart current_user.events.group(:app_name).count %>
</div>
在destroy.js中:
<% if @event.destroyed? %>
$('#event-' +<%= @event.id %>).slideUp();
$('.message' ).html('<div class="alert alert-success"><%= escape_javascript(flash.discard(:notice)) %></div>');
$('.message').toggle(1000);
$('.chart').html('<%= javascript_include_tag "//www.google.com/jsapi", "chartkick" %><%= pie_chart current_user.events.group(:app_name).count %>');
<% else %>
$('.message' ).html("<div class='alert alert-danger'><%= flash[:error] %></div>");
<% end %>
$(“#事件-”+).slideUp();
$('.message').html('');
$('.message')。切换(1000);
$('.chart').html('');
$('.message').html(“”);
所以我试图重新加载chart类,但它不起作用,我做错了什么
you can use location.reload()/window.location.reload().
方法的作用是:从当前URL重新加载资源。它的可选唯一参数是一个布尔值,如果为true,则会导致页面始终从服务器重新加载。如果为false或未指定,浏览器可能会从其缓存中重新加载页面
var intervalID = setInterval(function(){
$('.chart').each(function(){
$(this).load(this.href);
})
}, 900);
谢谢Haresh,但这将刷新页面。。我需要它只重新加载(',图表)选择器重试此。。。。。。var intervalID=setInterval(function(){$('.chart').each(function(){$(this.load(this.href);})},900);它没有任何作用