how to provide a click handler in JQCloud

强颜欢笑 提交于 2019-12-08 21:05:30

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/

A little different and maybe a easier way to implement it would be, to build your array like this:

var stuff = [];
stuff.push({"text":"n1","weight":23,"handlers" : {click: function(res) { alert("it worked for"+res.target.textContent);}}})

This will give you the value of the node you clicked on.

Or if you want to pass it to a function, you can use it like this:

stuff.push({"text":"n1","weight":23,"handlers" : {click: function(res) { run(res) }}})

function run(res){
alert("it worked for"+res.target.textContent);
}

Hope this solution helps!

you can always add a standard jquery handler for your click:

$(document).on('click', '#container-id .jqcloud-word', function() {
    var word_value = $(this).val();
    console.log(word_value);
});
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!