Topic: Removing a badge causes error in MDB deleteChip function

root-nine priority asked 5 years ago


Removing a chip that was peviously added by Javascript deletes the chip but also causes a "Cannot red property '-1' of undefined" error in MDB.js funtion deleteChip Can be reproduced on the  "Tags, Labels & Badges site" in section "Javascript usage" https://mdbootstrap.com/components/badges/#javascript-usage Also by simply removing the chips in "Set initial tags"

Piotr Glejzer staff commented 5 years ago

Hi, may you show me your code about that problem? Best, Piotr

Alex12345 free answered 3 years ago


I have the same problem. On page I have only one chip. When I try to delete itthe method _this2.deleteChip($chipsWrapper.data('index'), $chip.index(), $chipsWrapper); calls twice and on second call i got an error

mdb.js:24229 Uncaught TypeError: Cannot read property '-1' of undefined

at jQuery.fn.init.deleteChip (mdb.js:24229)
at HTMLElement.<anonymous> (mdb.js:24108)
at HTMLDocument.dispatch (jquery.js:5201)
at HTMLDocument.elemData.handle (jquery.js:5009)

Version: MDB Pro 4.7.7


Krzysztof Wilk staff commented 3 years ago

Hi!

Now there's no public method for deleting, so it won't work. The only way to delete is to click on the cross.

Best regards


root-nine priority answered 5 years ago


I´m just initializing the badges like in your sample: $(‘.chips-initial’).material_chip({ data: [{ tag: ‘Tag 1’, }, { tag: ‘Tag 2’, }, { tag: ‘Tag 3’, }], }); When I click on the cross to remove “Tag 1” the following error is listed in the browser console: Uncaught TypeError: Cannot read property ‘-1’ of undefined at x.fn.init.data.t.options.t.deleteChip (compiled-4.5.8.min.js?ver=4.5.8:1) at HTMLElement. (compiled-4.5.8.min.js?ver=4.5.8:1) at HTMLDocument.dispatch (compiled-4.5.8.min.js?ver=4.5.8:1) at HTMLDocument.m.handle (compiled-4.5.8.min.js?ver=4.5.8:1)

Piotr Glejzer staff commented 5 years ago

Yea I see it now. We will think about this. Do you have the same problem in your files?

root-nine priority commented 5 years ago

Yes I have, same problem in my files.

Piotr Glejzer staff commented 5 years ago

We are very sorry. We will try to figure out this problem.

Piotr Glejzer staff answered 5 years ago


JS usage is a premium component, and according to our system, you use MDB Free version. Please, provide us a number o your order or registered email to confirm your access to MDB Pro components and premium support. Send it to me on email: p.glejzer@mdbootstrap.com Best, Piotr

Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Priority
  • Premium support: Yes
  • Technology: MDB jQuery
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: Yes
Tags