Closed bernd-wechner closed 5 years ago
I slept on it and had a thought. Checked the documentation again and:
The first line says it. Doh! I've yet to implement a fix, but will close this if that document solves it for me (i.e. if DAL doesn't have some special approach).
Yep, confirmed this was the issue and solved with an ajax call.
I have a DAL widget and I'd like to set its values (multiselect) in Javascript.
Alas have spent hours trying and reading and failing.
There is conflicting advice on-line almost certainly related to versions of select2 and DAL but the latest Select2 doc:
https://select2.org/programmatic-control/add-select-clear-items#selecting-options
is clear. But if I try this I have no luck.
As this is a JS issue, I think we needn't dwell on the python side of it, or? And I would like to offer up a fair JS context to help assess. This is the rather complex widget DAL produced for me:
and folllowing the doc I try:
But nothing happens. Methinks the problem is the value simply isn't retained. I can do this in the browsers console:
If I select a view values in the browser itself (clicking the widget) I can then in the console see:
and after that oddly it works better but still weirdly. Take this console trace:
Wowsers. Flakey or what?
What gives here?