I am using JQCloud for building a tagcloud. It's nice and easy and meets my user's visual criteria. I would like to have a click handler invoked when user clicks on a word:
var tag_list = new Array();
for ( var i = 0; i < stuff.length; ++i ) {
var x = stuff[i];
tag_list.push({
text: x.NAME,
weight: x.COUNT,
//link: this.mkUrl(x),
click: function() { alert("it worked for " + x.NAME); },
html: {title: this.mkTooltip(x)}
});
}
$("#"+containerdivname).append( $("<div></div>", {id:"wordcloud"}));
$("#"+containerdivname).children("#wordcloud").jQCloud( tag_list );
The word cloud renders fine, has proper tooltip, but does not show an alert box on click. What am I doing wrong here?
Thanks
Handlers in JQCloud is supposed to be specified like this:
handlers : {click: function() { alert("it worked for" + x.NAME); }}
working example, http://jsfiddle.net/Q6348/7/