开发者

Can i pass a javascript object back to an atk4 page?

From an ATK4 page, i can call jqplot using a javascript helper file like this

on the page

   $chart = $p->add('jqplot', null, 'chart1');
   $chart->setSeries(array(10,20,15));

define a jqplot.php like this

class jqplot extends View {
  function render()
  {
    $plot=$this->js(true)->univ()->jqplot($this->series, $this->opts);
    parent::render();
    return $this;
  }
}

and in a js helper file, link the php call to the javascript

$.each({
 jqplot: function(series, opts){
   console.log('jqplot series',series);
   console.log('jqplot options开发者_JAVA百科',opts);
   $plot=$.jqplot(this.jquery.attr("id"), series, opts);
   return $plot;   
 }

}

If i have one chart on a page and reload it with an ajaxec call, it works fine but if i have several charts next to each other, only the first one is ok and the one next to it completely disappears if i call reload.

What i really want to do is call the jqplot replot function on the chart and pass it new data from the page but how can i do this ? The $plot object in the jshelper holds a javascript object and i need this object to call replot on it.

I am thinking maybe i can store the object when first created in a javascript associative array and then when i call replot, lookup the id and if found, call replot on the object but not sure what this code looks like or whether i have the right approach so any help appreciated.

Thanks in advance for you assistance.


It probably would be quite difficult to achieve this. First you need to properly handle destruction of jqPlot. You'll need a proper jQuery UI widget capable of restoring everything through a de-constructor. Then you might get it to work.

As far as Agile Toolkit is concern, it destroys the element containing your jqPlot using JavaScript, re-loads HTML and re-executes JavaScript.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜