0

I am a using ajax_select app for autocomplete, it is having its predefined JavaScript file for autocomplete, working fine for me, but I also want to add some extra paras in ajax call, now it is calling to url -

/ajax_select/ajax_lookup/sizes?term=lar

but what I want is:

/ajax_select/ajax_lookup/sizes?term=lar&filter=shoe

I tried many attempts but unable to add extra para because I am unable to understand how it is making ajax call and how it is passing parameters ?

There is no $.ajax function ! how it is going to possible ?

This is full code of that js file:

https://github.com/crucialfelix/django-ajax-selects/blob/develop/ajax_select/static/ajax_select/js/ajax_select.js

I have read the documentation, there is noting related to it because it is a django app, there is not much info about its JavaScript file.

I am not much familiar with JavaScript, anyone how can help me ?

Pankaj Sharma
  • 2,185
  • 2
  • 24
  • 50
  • Did you read the documentaion? http://django-ajax-selects.readthedocs.io/en/latest/ – charlietfl Jul 19 '18 at 12:41
  • there is a `data` property on the popup window, which seems to be used to build the data source for the autocomplete controls. around line 169. look in the markup. – Cee McSharpface Jul 19 '18 at 12:43
  • 1
    This is more of "tell me how to read the documentation, teach me to write the proper code" which is somewhat out of scope here - TRY, then post what you tried and we can help fix it. - post a full "working" example with any errors or issues noted. – Mark Schultheiss Jul 19 '18 at 12:43
  • yes, yes, I have read the documentation, there is noting related to it because it is a django app, there is not much info about its JavaScript file. – Pankaj Sharma Jul 19 '18 at 12:48
  • 1
    https://github.com/crucialfelix/django-ajax-selects/issues/231 – Confuzing Jul 19 '18 at 13:30

1 Answers1

1

I've no idea about django. If I didnt misunderstand; you are trying to add extra paramter to ajax request. I looked up github repo of "django-ajax-selects" which you use. The author says it depends on "jQuery UI AutoComplete" at repo's readme file. So you should search about "jQuery UI AutoComplete". You can add extra paramters to "jQuery UI AutoComplete" Please look here ; How do I pass an extra parameter to Jquery Autocomplete field? You should use jQuery UI AutoComplete's source method. Look at django-ajax-selects docs here for using source method: http://django-ajax-selects.readthedocs.io/en/latest/jQuery-plugin-options.html

Mehmet
  • 1,824
  • 3
  • 19
  • 28
  • 1
    thanks your suggestion helps me, I resolved it as, on change filter option - `$("#id_sizes_text").autocomplete({source:'/ajax_select/ajax_lookup/sizes?filter='+$(this).val()})` It is making ajax call with `.autocomplete` and it is initializing the source with DOM loaded, so change it. – Pankaj Sharma Jul 20 '18 at 10:25
  • @PankajSharma you are welcome. Sorry about my post, I didnt have too much time to format it. – Mehmet Jul 20 '18 at 10:47