I have been trying to use X-Editable http://vitalets.github.io/x-editable/ with Select2 https://select2.github.io/ for weeks now without much luck.
Originally I was trying to load in data from AJAX request and then use the library but all I could see if old code that supposedly worked with the older versions of both libraries.
To slightly simplify things I have now decided to load in my data separately so that X-Editable and Select2 only have to deal with an array of data that is already available.
My problem now is modifying the display of the data.
By default I am happy with the look of the edit field which looks like "tags" being selected.
When editing is completed and on initial page load, it shows my selected items as a comma separated string. I would like to modify that part to look different.
I saw some examples that worked as I want it to however they do not seem to work with the newer versions.
This JSFiddle here http://jsfiddle.net/jasondavis/j72k110m/ shows my desired output and functionality...almost but the catch is this demo is using older versions of the Select2 library. It has Select2 version v3.4.4 and X-Editable version v1.5.1
The latest version of Select2 is version v4.0.0 X-Editable is up to date at v1.5.1 as it has not been updated in a while.
On initial load and after selecting new value it should look like this below which means it wraps our selected value in a span
:
When clicked to edit the selected values, it should look like this which looks like "tags" however it should not show the <span>
part!
In this JSFiddle http://jsfiddle.net/jasondavis/N6bQE/320/
I have updated Select2 to the new version and I am trying to replicate the functionality from the other JSFiddle above by showing the selected values as "tags".
Another issue with this version is that when selecting values, it does not remove an option from the dropdown list. So even though 1 item is selected already, it still shows up as an option to click on again!
The other issue is that new selected items do not get added on the non-edit screen.
More images below to show what I mean...
Image below shows the intial screen load selected items and also items that are selected and not in edit-mode. The issue is that it is not updating with new items that are selected. Also it shows the selected ID's instead of a title/name
My end goal is to simply use Select2 on my X-editable field to allow the selection of an Assigned User. Selected assigned users will show a gravatar thumbnail image and the user name.
Both Select2 and X-Editable allow the use of a template style output to modify there output however when they are working together, there default functionality is different and those output modification functions do not work the same as they do when running either library on it;s own.
I know what I want can be done since the 2 libraries are meant to work together, it's just a matter of getting the newer versions of Select2 to work with the older version of X-Editable which has not been updated in a long time sadly!