javascript - Reload charkick pie_chart without refreshing the page -


my goal once delete action submitted chart should update it's values without refreshing page here code:

in 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(:app_name).count %> </div> 

in 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 %> 

so i'm trying reload chart class it's not working, doing wrong?

you can use location.reload()/window.location.reload(). 

the location.reload()method reloads resource current url. optional unique parameter boolean, which, when true, causes page reloaded server. if false or not specified, browser may reload page cache.

var intervalid = setinterval(function(){    $('.chart').each(function(){       $(this).load(this.href);    }) }, 900); 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -