0

I would like to use tag-it to make lables all uppercase.

$('#taglabel').tagit({
   availableTags: ['this','label1']
});

how do i join preprocessTag method with available tags?

should i use it

$('#taglabel').tagit({
 "preprocessTag", function(val) {
  if (!val) { return ''; }
  return val[0].toUpperCase() + val.slice(1, val.length);
});
tada
  • 11
  • 2

1 Answers1

0

The right syntax is :

$("#tag-it".tagit({
  availableTags: ["...","..."],
  ...
 });

and then

// ensure all tags are capitalized
$("#tag-it").tagit("preprocessTag", function(val) {
   if (!val) { return ''; }
   return val[0].toUpperCase() + val.slice(1, val.length);
});

is the only way

UPDATE

you're syntax :

    $('#taglabel').tagit(  { <-- this curly brace is wrong
    "preprocessTag", function(val) {
      if (!val) { return ''; }
      return val[0].toUpperCase() + val.slice(1, val.length);
    });
steo
  • 4,586
  • 2
  • 33
  • 64
  • I want the new tags added to be uppercases as well...hence want to use preprocessTags. Not sure how to use that? – tada Jul 18 '13 at 10:50
  • when you use tagit, how to add available Tags and also use preprocessTag? Is my question clear? – tada Jul 18 '13 at 10:53
  • that does not work as preprocess is not event it is method call – tada Jul 18 '13 at 10:55
  • Yeah i just noticed it, so you need to call first available and then preprocess – steo Jul 18 '13 at 10:56
  • Use my syntax ,which is taken from the official documentation, not yours. You're using "{" which is for option, not for method – steo Jul 18 '13 at 10:58
  • neither of them works. that is tag prepopulates but are NOT upper cased. – tada Jul 18 '13 at 11:00
  • i used your syntax correct one, but as i mentioned it does nto upper case the tags.Also is $("#tag-it".tagit({ purposely written that way....shouldnt it be $(("#tag-it").tagit({ – tada Jul 18 '13 at 11:03
  • maybe because availableTags does not call createTag.. try to manually create them and check out, just for curiosity.. – steo Jul 18 '13 at 11:04