categoryFilter isn't properly firing the statechange event

65 views
Skip to first unread message

Benjamin Press

unread,
Jun 20, 2012, 4:27:09 PM6/20/12
to google-visua...@googlegroups.com
On load, the CategoryFilter will fire a statechange event, but once loaded, deselecting or selecting a value does not fire the event. I can't figure out why, but this is the case. Here is the code that I'm using:

http://jsfiddle.net/D6ztF/4/

Please, if someone could let me know why the graph isn't being re-drawn when you change what's selected, I'd be really appreciative.

Benjamin Press

unread,
Jun 20, 2012, 4:41:04 PM6/20/12
to google-visua...@googlegroups.com
Actually, I figured it out on my own, but for anyone who is interested:

For some reason, this line:
"google.visualization.events.addListener(categoryPicker,'statechange',onControlStateChange());" immediately calls onControlStateChange.

remove the () from it to fix it:
"google.visualization.events.addListener(categoryPicker,'statechange',onControlStateChange);"

For some reason, this works.

asgallant

unread,
Jun 20, 2012, 11:42:53 PM6/20/12
to google-visua...@googlegroups.com
Yes, you are correct, but this is not strange behavior.  This:

google.visualization.events.addListener(categoryPicker,'statechange',onControlStateChange()); 

calls the function, while this:

google.visualization.events.addListener(categoryPicker,'statechange',onControlStateChange);

passes the function as an argument to the event addListener function.  The first case would be valid only if the "onControlStateChange" function returns a function.
Reply all
Reply to author
Forward
0 new messages