H Dindi H Dindi - 3 months ago 15
jQuery Question

Bootstrap TypeHead change the seperator character

I am using the following bootstrap type head character : http://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/ in creating sentences, The plugin works fine but I would like to change the separator character which currently is a comma to another special character e.f ; or $ or # from , how can I achieve this ?
Below is my code :

var x = jQuery.noConflict();
x(document).ready(function () {
x(".inputs").tagsinput('items');

x(".activities").tagsinput('items');
x(".outputs").tagsinput('items');
x(".shortterm").tagsinput('items');
x(".intermediate").tagsinput('items');
x(".longterm").tagsinput('items');

});

Answer

From the docs of the plugin you are using, you can specify the confirmKeys option which:

Array of keycodes which will add a tag when typing in the input. (default: [13, 188], which are ENTER and comma)

So if you wanted to add ; for example, you would use the ASCII code 59:

$('input').tagsinput({
  confirmKeys: [13, 188, 59]
});

Other codes are:

$ 36
# 35