Replies: 5 comments
-
I'll need to look into this but I'm not sure if there is an elegant solution. We are marshalling data between PHP on the server side to Javascript on the client side. JSON does not allow functions, it is a data-interchange format only, and there is no way to represent Javascript functions on the PHP side except as a string regardless. |
Beta Was this translation helpful? Give feedback.
-
It might help to know your use case, there may be another direction to attack from. |
Beta Was this translation helpful? Give feedback.
-
I think you just need to specify the function name without quotes. In the Select2 docs, they show examples of this for the callback functions:
I have a few different use cases. For example, I was trying to use the matcher callback to customize the search results list. In another example, I was trying to use the templateResut and templateSelection callbacks to customize the appearance of the data, adding icons, etc... |
Beta Was this translation helpful? Give feedback.
-
The problem with that is two-fold:
Since you have custom Javascript for your callback functions it makes more sense to me if we expose a convenient way to set the callbacks on the Javascript side. |
Beta Was this translation helpful? Give feedback.
-
Yes, that would be a fine solution. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The pods_pick_select2_overrides filter works well for overriding simple options. However, it doesn't work with the Select2 callback options, because it passes the function name as a string, but Select2 is expecting it to be passed as a function (without quotes).
Beta Was this translation helpful? Give feedback.
All reactions