Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/385.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用JQuery调用JSF元素注册的java脚本方法?_Javascript_Jquery_Jsf - Fatal编程技术网

Javascript 如何使用JQuery调用JSF元素注册的java脚本方法?

Javascript 如何使用JQuery调用JSF元素注册的java脚本方法?,javascript,jquery,jsf,Javascript,Jquery,Jsf,我的jsf页面中有一些selectBooleanCheckbox元素。所有元素都有一个javaScript函数,该函数在属性onchange处绑定: <h:selectBooleanCheckbox value="#{bean.value_1}" onchange="updating(this, '#{textprop.value_1}', '#specific_html_dom_element');"/> 取消选择复选框的JQuery代码: jQuery('.class_1').

我的jsf页面中有一些selectBooleanCheckbox元素。所有元素都有一个javaScript函数,该函数在属性onchange处绑定:

<h:selectBooleanCheckbox value="#{bean.value_1}" onchange="updating(this, '#{textprop.value_1}', '#specific_html_dom_element');"/>
取消选择复选框的JQuery代码:

jQuery('.class_1').find('input[type="checkbox"]').each(function() {         
    jQuery(this).attr("checked","").val("0");
}); 
当前的问题是,如果执行JQuery功能,java脚本方法更新将不会执行。如果我选择或取消选择一个selectBooleanCheckbox,javascript方法将被执行。更新方法为每个复选框获取不同的参数值

我怎样才能解决这个问题

onchange仅在用户选中/取消选中时激发

设置值后,可以手动调用onchange事件:

jQuery('.class_1').find('input[type="checkbox"]').each(function() {         
   jQuery(this).attr("checked","checked").val("1");
   jQuery(this).change();// manual call
});
或者,您可以使用以下命令触发事件:

jQuery('.class_1').find('input[type="checkbox"]').each(function() {         
   jQuery(this).attr("checked","checked").val("1");
   jQuery(this).trigger("change");
});
希望这有帮助

jQuery('.class_1').find('input[type="checkbox"]').each(function() {         
   jQuery(this).attr("checked","checked").val("1");
   jQuery(this).trigger("change");
});