kasopey
kasopey

Reputation: 375

Toggle <p:selectCheckboxMenu> items in JavaScript

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.

Upvotes: 0

Views: 1139

Answers (1)

kasopey
kasopey

Reputation: 375

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.

Upvotes: 1

Related Questions