django-autocomplete-light
django-autocomplete-light copied to clipboard
how to change selection in version django-autocomplete-light 3.7.0.dev0 using autocomplete.ModelSelet2 widget with jquery. Python 3.8.0, Django 3.0.8
I tried $(element).val(id).trigger('change') but not changing selection. As mentioned above using django-autocomplete-light 3.7.0.dev0 autocomplete.ModelSelect2 widget. I could address the element in jquery but selection not changing. When making a selection in the widget it is responding to the jquery call and getting $(element).val(). But when i try change selection using $(element).val(id).trigger('change') not changing. Could someone help me out?
Can you try with 3.8.1 ? There is an update of select2 that fixes quite some bugs.
Dear jpic, I tried but no success.
Sent from Yahoo Mail on Android
On Thu, 15 Oct 2020 at 3:56 pm, jpic ∞[email protected] wrote:
Can you try with 3.8.1 ? There is an update of select2 that fixes quite some bugs.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
I also tried this:
$('select.js-example-basic-single').val('WY')
On their example page : https://select2.org/getting-started/basic-usage
As documented by https://select2.org/programmatic-control/add-select-clear-items#selecting-options
And no luck for me too.
Have you tried opening an issue on select2 ? Would be nice to link it here ;)
Dear jpic, Let me make this clear with django-select2 it works fine, the only issue is during loading with multiple instances and a big list in drop down. That's why I tried Dal with Dal loading is ok, but programatic change of value with jQuery is an issue as explained.
Sent from Yahoo Mail on Android
On Thu, 15 Oct 2020 at 4:17 pm, jpic ∞[email protected] wrote:
I also tried this: $('select.js-example-basic-single').val('WY')
On their example page : https://select2.org/getting-started/basic-usage
As documented by https://select2.org/programmatic-control/add-select-clear-items#selecting-options
And no luck for me too.
Have you tried opening an issue on select2 ? Would be nice to link it here ;)
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
In django-select2 master they have select2 4.0.12, in dal 3.8.1 it's select2 4.0.13.
But what I'm wondering is how what you're trying to do is supposed to work, because DAL will just render an empty select if there is not selected value.
So, I don't think using .val() to set a value will do anything, unless a option tag with the corresponding value was added to the select tag priorly ?