I have multiple select2s on one page. All do the same ajax call, but with one different parameter. So, it would be nice, to have only one controller for all select2s.
In this example I have two select2s. The first makes an ajax call to URL?search=XYZ&attribute=city. The second makes an ajax call to URL?search=XYZ&attribute=street.
I have multiple select2s on one page. All do the same ajax call, but with one different parameter. So, it would be nice, to have only one controller for all select2s.
In this example I have two select2s. The first makes an ajax call to URL?search=XYZ&attribute=city. The second makes an ajax call to URL?search=XYZ&attribute=street.
The solution is simple. You could change the code
to
Than you can access the select2-element attributes in options-function:
Thank you.