Datatables Editor and Jquery UI Autocomplete
Datatables Editor and Jquery UI Autocomplete
menashe
Posts: 196Questions: 43Answers: 2
I have successfully implemented jQuery UI Autocomplete in an Editor. I get the expected values and am able to choose.
However, I am CLUELESS (and have wasted "day") trying to figure out how the return value from autocomplete is propagated in order to save in my server side ajax call.
I have looked at the various discussion threads that relate to autocomplete.
This question has an accepted answers - jump to answer
Answers
Are you tied to jQuery UI AutoComplete? Personally I really don't like it because of how difficult it is to separate labels from values. If you just have an array of values which are also labels, then its fine, but if you are looking for more of a regular
<select>
replacement, I'd use Select2.When you select a value from the AutoComplete dropdown it should populate that into the
input
element. Does that not happen? That is then used as the value to submit when the Editor form is submitted.Allan
Allan,
Thank for the response.
"Tied" to it? No! I was literally sitting here at my computer looking up Select2 when I saw your response!
With jQuery UI Autocomplete:
I select and it DOES populate the input. I think I'm just stumped on this--how do I get this value that is (as you said) "then used as the value to submit when the Editor form is submitted."?
I am able to "pick up" the label, but I do not see how to populate the foreign key with the value?
(I am assuming that the same issue will apply in Select2?)
When it is in the input field, that's the value set. You then press submit and it would submit like like a
text
field in Editor.If you are using a different label from the value, I'd move away from jQuery UI AutomComplete (assuming you have the option to do that) and use Select2.
I'd also suggest starting with a simple
select
such as in this example and then adding Select2 on top of that.Allan
Hi Allen,
Getting there--I believe!
This is (I believe) the relevant part of my field definition:
You'll notice that I return the "id" and the "text". The Select2 values display properly.
Now, when I choose a value from the Select2, I need the corresponding "id: to update the "manufacturer_id" below in the request being sent back to the server. This is what I am missing!!
Allan,
I figured it out!
Select2 is definitely simpler than jQuery UI Autocomplete.
The issue: In spinning my wheels for almost a week trying to make sense of autocomplete, I commented this out and that out... repeatedly. When I restored a critical one-line function--it works!
Thank you for your help! I absolutely love your product!
Brilliant - delighted to hear you managed to get it working .
And yes, Select2 is a serious level up from jQuery UI AutoComplete... I should perhaps put a warning on the AutoComplete page.
Allan