Ruby on Rails Thursday, February 25, 2016

So in your _chart8 partial you are populating chart.series.data using the proved startdate and enddate variables.  You will want to change these values when your ajax function returns data meaning you should first persist your chart object instead of just creating it without assignment.  

Something simple would be
 $(function() { 
    window.chart8 = new Highcharts.Chart({ 
    // etc...

Once this chart is accessible you can update your ajax query to do something like this (forgive me I'm not familiar with the Chart API you are using)
$.ajax({ 
          url: "/charts", 
          type: 'POST', 
          data: { startdate: newstartdate, enddate : newenddate}, 
          cache: false, 
          dataType: 'json' 
      }).done(function(data) { 
        window.chart8.series.data = data // or some such thing
      }).fail(function(msg) { 
        //something went wrong with the request
      });

Again browse through the documentation at http://api.jquery.com/jquery.ajax/

Hope this gives you a good direction. 

On Thursday, February 25, 2016 at 10:12:33 AM UTC-8, Ruby-Forum.com User wrote:
I think I understand what you are saying to do, but an example would be
helpful...  I am far from a JQuery expert...  :-)

John

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/7aedb0ef-898d-48da-848c-663b2a3b9352%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment