1
0
mirror of synced 2024-11-25 22:36:03 +03:00

Add the ability to specify custom tags separator.

Signed-off-by: Igor Vaynberg <igor.vaynberg@gmail.com>
This commit is contained in:
Grzegorz Kaczan 2012-07-06 14:20:48 +02:00 committed by Igor Vaynberg
parent 4489ab7769
commit 5aae33d789

View File

@ -534,6 +534,9 @@
this.select = select = opts.element;
}
//Custom tags separator.
opts.tagSeparator = opts.tagSeparator || ",";
if (select) {
// these options are not allowed when attached to a select because they are picked up off the element itself
$.each(["id", "multiple", "ajax", "query", "createSearchChoice", "initSelection", "data", "tags"], function () {
@ -663,7 +666,7 @@
opts.createSearchChoice = function (term) { return {id: term, text: term}; };
opts.initSelection = function (element, callback) {
var data = [];
$(splitVal(element.val(), ",")).each(function () {
$(splitVal(element.val(), opts.tagSeparator)).each(function () {
data.push({id: this, text: this});
});
@ -1467,7 +1470,7 @@
opts = $.extend({}, {
closeOnSelect: true
}, opts);
// TODO validate placeholder is a string if specified
if (opts.element.get(0).tagName.toLowerCase() === "select") {
@ -1827,7 +1830,7 @@
return val === null ? [] : val;
} else {
val = this.opts.element.val();
return splitVal(val, ",");
return splitVal(val, this.opts.tagSeparator);
}
},