How can I select or unselect items in <p:selectCheckboxMenu>
component using JavaScript?
I have figured out only this way:
PF('selectCheckboxMenuWidgetVar').checkboxes[index_of_item].click();
But this generates "click" on element and invokes all handlers. I want only (un)select item without invoking handlers.
答案 0 :(得分:1)
I found an answer:
var widgetVar = PF('selectCheckboxMenuWidgetVar');
check:
widgetVar.check($(widgetVar.checkboxes[index_of_item]));
$(widgetVar.inputs[index_of_item]).prop('checked', true);
uncheck:
widgetVar.uncheck($(widgetVar.checkboxes[index_of_item]));
$(widgetVar.inputs[index_of_item]).prop('checked', false);
it is working for me.