I’m using Flot to graph data and I can mimic the turning series on/off like the example here: http://people.iola.dk/olau/flot/examples/turning-series.html.
I’m trying to draw a bunch of different graphs on one page so I separated things into separate functions and everything works except the check boxes no longer turn the series on/off.
Does anyone have an idea of how this line works:
choiceContainer.find("input").click(plotAccordingToChoices);
Why isn’t it:
choiceContainer.find("input").click(plotAccordingToChoices());
I changed plotAccordingToChoices() to a function that receives parameters, and changed the .click() to:
choiceContainer.find("input").click(plotAccordingToChoices(foo1,foo2,foo3));
which breaks the series on/off functionality.
Any ideas on why this might be happening?
It’s ‘function’, not ‘function()’, because you pass a reference to that function to the click function.
Writing function() literally calls it. You want to pass a reference to the click function instead.
Pages like these explain it. http://www.cristiandarie.ro/asp-ajax/Delegate.html