Callback actions raise error in select2 pattern
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 57
- Forks
- 103
- Avg merge
- 10h 25m
- Merged PRs (30d)
- 18
Description
On Plone 6.1, I'm trying to use the select2 pattern with callback action for onSelected (but this also applies to onSelecting, onDeselecting, onDeselected).
If I pass the callback as a string referencing an existing JS function via pattern options (options["onSelected"] = "myFunction"), the JS throws an error at this line after a selection has been made in the select2 field :
https://github.com/plone/mockup/blob/253d77a91ac159c2c57c75eda129d9d2aabaf4df/src/pat/select2/select2.js#L133
Uncaught TypeError: this is undefined
The function is never called.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/pat/select2/select2.js at the linked line where the onSelected callback is handled. Reproduce the issue with a select2 pattern option such as options["onSelected"] = "myFunction", then inspect the callback invocation and compare it with the other listed callback actions. Done means a callback supplied as a string is invoked after selection without the “this is undefined” error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100