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