【问题标题】:Uncaught TypeError: Object [object Object] has no method 'tagsInput'未捕获的类型错误:对象 [object Object] 没有方法“tagsInput”
【发布时间】:2013-03-15 20:23:54
【问题描述】:

我的php代码是这样的

<div class="field">                 
    <label  style="float: none;">Recipients (by username):</label>
    <?=form_error('to')?>
    <input id="to" name="to" type="text" value="<?=$form_to?>" class="taglist"  />
</div>

我已包含 jquery.tagsinput.css

我还添加了脚本

$('.taglist').tagsInput({
        'height':'27px',
        'width':'400px',
        'defaultText':'add recepient',
    });

但我在控制台中收到以下错误:

Uncaught TypeError: Object [object Object] has no method 'tagsInput'

任何想法.. 可能是什么问题?谢谢。

【问题讨论】:

  • 你添加了javascript源文件吗?
  • 导入css文件不会神奇地为jquery添加js函数。
  • 它也需要tagsInput js文件。
  • @limelights 我的愚蠢错误。我已经包含了 js 文件并且一切正常。谢谢。
  • @sharmacal 酷。酷,酷,酷。

标签: jquery


【解决方案1】:

看起来你忘了添加 tagsinput js 脚本..(显然是 jquery.js)

这里在&lt;head&gt;标签中添加这个

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

<script src="http://xoxco.com/projects/code/tagsinput/jquery.tagsinput.js"></script>

如果你已经下载了文件然后.. 给你的 taginputs js 文件的正确路径..

<script src="path/to/your/file/jquery.tagsinput.js"></script>

【讨论】:

    猜你喜欢
    • 2014-01-08
    • 2013-04-19
    • 2012-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多