Juri
Juri

Reputation: 1741

PrimeNG multiselect onItemClick not working after update to 7

I have an MultiSelectComponent which extends primeng MultiSelect

After update from 6.1.6 to 7.0.4

<ul class="not-important"
   <li *ngFor="let option of options; let i = index" class="not-important"
   (click)="onItemClick($event, option)"

Property 'onItemClick' does not exist on type 'MultiSelect'. What is the replacement? Can't find something in documentation...

Upvotes: 0

Views: 2559

Answers (2)

Juri
Juri

Reputation: 1741

i have found a solution (no clue what happened on primeng)

public onMyClick(event: any, option: any): void {
    event.option = option;
    super.onOptionClick(event);
}

Call onMyClick on click event on <li> item.

Upvotes: 1

Jamie Rees
Jamie Rees

Reputation: 8183

Looking at the documentation it looks like they have not updated it.

After looking at the source code, you should now be using onOptionClick()

You can see the changes here: https://github.com/primefaces/primeng/commit/993f856be9bb864057753e3a9c033f0d60ad7334#diff-3bc7dd3fc5e401bc174d2d8475540a34

So you would need to change your code to

<ul class="not-important"
   <li *ngFor="let option of options; let i = index" class="not-important"
   (click)="onOptionClick($event, option)"

I have raised an issue with the PrimeNG team to correct the documentation

Upvotes: 1

Related Questions