<script type="text/javascript>
function submitMe() {
var checked_ids = [];
$('#your-tree-id').jstree('get_checked',null,true).each(function(){
checked_ids.push(this.id);
});
//setting to hidden field
document.getElementById('jsfields').value = checked_ids.join(',');
}
</script>
<input type="hidden" name="jsfields" id="jsfields" value="">
我正在搜索表单提交的Jstree的检查ID。所以这就是我得到的。但是,我如何在我的程序中调用此函数?
答案 0 :(得分:0)
使用点击/提交活动
$(form).submit(submitMe);
或
$('[type="submit"]').click(submitMe);
不要忘记阻止默认事件,然后在代码后触发它:
function submitMe(e) {
e.preventDefault();
var checked_ids = [];
$('#your-tree-id').jstree('get_checked',null,true).each(function(){
checked_ids.push(this.id);
});
//setting to hidden field
document.getElementById('jsfields').value = checked_ids.join(',');
window.location = $(this).closest('form').submit();
}