I have a requirement that a user can pick 4 names from autocomplete and specify one of those will be primary name. When submiingt the form, I should capture all 4 values from the server and identify which one is primary . I am planning to use selectable widget
. Is there any way I can pass selected value along with other unselected values as well in the below example? here is the fiddle sample JSFIDDLE DEMO
$("#selectable").selectable({
stop: function() {
var items = '';
var result = $("#select-result").empty();
$(".ui-selected", this).each(function() {
var index = $("#selectable li").index(this);
items += (" #" + (index + 1));
});
alert('You have selected: ' + items);
$('input[name="horario"]').val(items);
}
});
You can do as the following, using this selector you get the unselected items:
using this binding on the element it will be unselected when you click on it, so you don't need a remove button-icon:
Code:
Demo: http://jsfiddle.net/IrvinDominin/bZKt6/