diff --git a/docs/_includes/options/dropdown/tagging.html b/docs/_includes/options/dropdown/tagging.html index 7ab3fe8c..43e1eb01 100644 --- a/docs/_includes/options/dropdown/tagging.html +++ b/docs/_includes/options/dropdown/tagging.html @@ -19,18 +19,57 @@ $('select').select2({ Does tagging work with a single select? +

+ Yes. +

+ {% include options/not-written.html %}

How do I add extra properties to the tag?

+{% highlight js linenos %} +$('select').select2({ + createTag: function (params) { + var term = $.trim(params.term); + + if (term === '') { + return null; + } + + return { + id: term, + text: term, + newTag: true // add additional parameters + } + } +}); +{% endhighlight %} + {% include options/not-written.html %}

Can I control when tags are created?

+{% highlight js linenos %} +$('select').select2({ + createTag: function (params) { + // Don't offset to create a tag if there is no @ symbol + if (params.term.indexOf('@') === -1) { + // Return null to disable tag creation + return null; + } + + return { + id: params.term, + text: params.term + } + } +}); +{% endhighlight %} + {% include options/not-written.html %}