1

我的引导标签字段不适用于 typehead。我的引导版本是 2.3,我正在使用 yii2 框架。

HTML:

  <input type="text" id="tags"
         value="<?php echo   $model->tags;?>"/>   

脚本:

  var colors = ["red", "blue", "green", "yellow", "brown", "black"];
  $('input[type=text][id="tags"]').tagsinput({
  typeahead: {
  source: function(query) {
  return colors;
  }
  }
  });

错误

   TypeError: text is undefined

   matcher()bootst...nput.js (line 278)
   text = undefined
    transition()bootstrap.min.js (line 6)
    a = undefined
    f()jquery.min.js (line 2)
    a = function()
    b = function()
    c = false
    transition()bootstrap.min.js (line 6)
    b = undefined
    transition()bootstrap.min.js (line 6)
    a = Object { originalEvent=Event keyup, type="keyup", timeStamp=16416032, more...}
    (?)()analyse?id=3 (line 2)
    H()jquery.min.js (line 3)
    c = Object { originalEvent=Event keyup, type="keyup", timeStamp=16416032, more...}
    H()jquery.min.js (line 3)
    a = keyup charCode=0, keyCode=82

    return (text.toLowerCase().indexOf(this.query.trim().toLowerCase()) !== -1);

有任何想法吗?

4

0 回答 0