Commits

Ralph Bean committed 0e4183d

Broke callback out into a closure

Comments (0)

Files changed (2)

 
 setup(
     name='tw2.jquery.plugins.jqplot',
-    version='2.0b1',
+    version='2.0b2',
     description='toscawidgets2 wrapper for the jqPlot jQuery plugin',
     long_description=long_description,
     author='Ralph Bean',

tw2/jquery/plugins/jqplot/static/js/jqplot-utils.js

         $.jqplot(sel, data, options);
 }
 
-function doPollingJQPlotWidget(sel, data, options, url, url_kwargs, interval){
-        $.jqplot.config.enablePlugins = true;
-
-        // Setup our initial plot
-        var the_plot_thickens = $.jqplot(sel, data, options);
-
-        // Setup our callback function
-        callback = function (json) {
-                pl = the_plot_thickens;
-
+// closure
+function make_jqplot_async_callback(pl) {
+        return function (json) {
                 for ( _i = 0; _i < json.data.length; _i++ ) {
                         pl.series[_i].data = json.data[_i] ;
                 }
                 }
                 pl.redraw();
         };
+}
+
+function doPollingJQPlotWidget(sel, data, options, url, url_kwargs, interval){
+        $.jqplot.config.enablePlugins = true;
+
+        // Setup our initial plot
+        var the_plot_thickens = $.jqplot(sel, data, options);
+
+        var callback = make_jqplot_async_callback(the_plot_thickens);
 
         // Finally make the JSON call
         $.getJSON(url, url_kwargs, callback);