admin管理员组文章数量:1025549
I have got jsTree and a button. jsTree has select_node function
.bind("select_node.jstree", function (event, data) {
// some code
})
is it possible to trigger select_node event on button click?
I have got jsTree and a button. jsTree has select_node function
.bind("select_node.jstree", function (event, data) {
// some code
})
is it possible to trigger select_node event on button click?
Share Improve this question edited Jan 20, 2012 at 13:50 greut 4,3731 gold badge31 silver badges49 bronze badges asked Jan 20, 2012 at 13:46 Iurii DziubanIurii Dziuban 1,0912 gold badges18 silver badges31 bronze badges3 Answers
Reset to default 0The way to use anything you bind
ed in jQuery is done via trigger
(or triggerHandler
).
.trigger('select_node.jstree', data)
See: http://api.jquery./trigger/
you could write a
function onSelectNode(selectedNode) {/* do stuff */}
and then you can call it in your event bind like this
.bind("select_node.jstree", function (event, data) {
onSelectNode(data.node);
})
and then instead of trying to trigger 'select_node' yourself you can just call
onSelect(treeInstance.get_selected(true)[0])
note: you must have already saved the reference of tree in a variable in global scope to access it later
treeInstance = $('#div').jstree(true);
You can trigger the select_node.jstree using trigger i.e
.trigger('select_node.jstree', data)
where data is plete node that you need to select
I have got jsTree and a button. jsTree has select_node function
.bind("select_node.jstree", function (event, data) {
// some code
})
is it possible to trigger select_node event on button click?
I have got jsTree and a button. jsTree has select_node function
.bind("select_node.jstree", function (event, data) {
// some code
})
is it possible to trigger select_node event on button click?
Share Improve this question edited Jan 20, 2012 at 13:50 greut 4,3731 gold badge31 silver badges49 bronze badges asked Jan 20, 2012 at 13:46 Iurii DziubanIurii Dziuban 1,0912 gold badges18 silver badges31 bronze badges3 Answers
Reset to default 0The way to use anything you bind
ed in jQuery is done via trigger
(or triggerHandler
).
.trigger('select_node.jstree', data)
See: http://api.jquery./trigger/
you could write a
function onSelectNode(selectedNode) {/* do stuff */}
and then you can call it in your event bind like this
.bind("select_node.jstree", function (event, data) {
onSelectNode(data.node);
})
and then instead of trying to trigger 'select_node' yourself you can just call
onSelect(treeInstance.get_selected(true)[0])
note: you must have already saved the reference of tree in a variable in global scope to access it later
treeInstance = $('#div').jstree(true);
You can trigger the select_node.jstree using trigger i.e
.trigger('select_node.jstree', data)
where data is plete node that you need to select
本文标签: javascriptjsTree trigger selectnode functionStack Overflow
版权声明:本文标题:javascript - jsTree trigger select_node function - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745613439a2159142.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论