0

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...

Juri
  • 1,531
  • 2
  • 20
  • 43

2 Answers2

1

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

Jamie Rees
  • 7,973
  • 2
  • 45
  • 83
  • not working: TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'EventEmitter' has no compatible call signatures. – Juri Jan 09 '19 at 15:58
  • there is onClick on MultiSelectItem but not on MultiSelect – Juri Jan 09 '19 at 16:11
  • If you look at the github commit, you can see that they renamed `onItemClick` to onOptionClick` on the MultiSelect Component. – Jamie Rees Jan 09 '19 at 16:14
  • tried this with $event but... ERROR TypeError: Cannot read property 'disabled' of undefined – Juri Jan 09 '19 at 16:20
  • Your code in question does not show any `disabled` properties. So I'm not sure how to help with that. – Jamie Rees Jan 09 '19 at 16:22
  • appreciated for your help. Have found a solution – Juri Jan 10 '19 at 08:54
1

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.

Juri
  • 1,531
  • 2
  • 20
  • 43