how to get the id of a django-autocomplete element to use in jquery script

26 views
Skip to first unread message

Nijo Joseph

unread,
Nov 2, 2019, 8:40:20 AM11/2/19
to yourlabs
Hi all,

     Please help me to get the id of django autocomplete light element, so i can call an event in jquery like change or so.


<div class="col-xs-4" data-select2-id="12">
<select name="client" class="form-control select2-hidden-accessible" required="" id="id_client" data-autocomplete-light-language="en" data-autocomplete-light-url="/trans/client-autocomplete" data-autocomplete-light-function="select2" data-select2-id="id_client" tabindex="-1" aria-hidden="true">
  <option value="" selected="" data-select2-id="1">---------</option>

<option value="1" data-select2-id="15">Nijo Joseph</option></select><span class="select2 select2-container select2-container--default select2-container--below select2-container--focus" dir="ltr" data-select2-id="2" style="width: 486.388px;"><span class="selection"><span class="select2-selection select2-selection--single form-control" role="combobox" aria-haspopup="true" aria-expanded="false" tabindex="0" aria-labelledby="select2-id_client-container"><span class="select2-selection__rendered" id="select2-id_client-container" role="textbox" aria-readonly="true" title="Nijo Joseph">Nijo Joseph</span><span class="select2-selection__arrow" role="presentation"><b role="presentation"></b></span></span></span><span class="dropdown-wrapper" aria-hidden="true"></span></span>
   
</div>
<script>
    $("#id_client").change(function () {
          var id = $(this).val();
  alert("hai");
      });

</script>

Not working.

Nijo Joseph

unread,
Jul 30, 2020, 5:01:30 PM7/30/20
to yourlabs
Hai,
 Use version dal3.7.0.dev0. ie. pip install django-autocomplete-light==3.7.0.dev0.
Reply all
Reply to author
Forward
0 new messages