After spending some time with Firebug to find and fix a couple of typos, I've got it working now. There seems to be no way around explicitly referring to the SPAN element (see below), but I can live with that.
Now I need to tackle the next level, which is to expand the server- side JSON function to return data for multiple sparklines on a page and arrange to call sparkline() with the right data for each of the corresponding elements. Thanks again for the help! Here's what's working correctly: In the view ... <script type="text/javascript"> /* <![CDATA[ */ $(function() { $('.dynamicsparkline').everyTime(1000,function(i) { var j = 2+i%5; $.getJSON('{{=URL(r=request,f='call/json/ sparkdata')}}/'+j, function(data) { var sparkdata = [10,9,8,7,6,5,4]; for(var k=0; k<sparkdata.length; k++) { sparkdata[k] = data.a[k];} console.log("sparkdata = " + sparkdata); $('.dynamicsparkline').sparkline(sparkdata); // WORKS // $(this).sparkline(sparkdata) // DOES NOT WORK! }); }); }); /* ]]> */ </script> <h1>This is the sparkline.html template</h1> <p> Sparkline with dynamic data: <span class="dynamicsparkline">Loading..</ span> </ p> and in the controller ... @service.json def sparkdata(j): sys.stderr.write("\nsparkdata() called with j=%d\n"%int(j)) j = int(j) return dict(a=[n%j for n in [10,9,8,7,6,5,4]]) Cheers, Mike On May 14, 9:51 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > aha try replace > > $(function() { > $('.dynamicsparkline').everyTime(1000,function(i) { > $.getJSON('{{=URL(r=request,f='call/json/ > datapoints')}}/'+i, function(data) { > var b = [0,0,0,0,0,0,0] > var j = 2+i%5; > for(var k=0; k<b.length; k++) { b[k] = data.a[k] > %j;} > $(this).sparkline(b); > }); > }); > }); > > with > > $(function() { > $('.dynamicsparkline').each(function(index){ > var obj=$(this); > obj.everyTime(1000,function(i) { > $.getJSON('{{=URL(r=request,f='call/json/ > datapoints')}}/'+i, function(data) { > var b = [0,0,0,0,0,0,0] > var j = 2+i%5; > for(var k=0; k<b.length; k++) { b[k] = data.a[k] %j;} > obj.sparkline(b); > }); > }); > }); > });