2

I am using the jQuery tagit! library to create a user "Skills" input form. I figured this would be an extremely quick and simple setup like most jQuery libraries, however I am having a tremendous amount of trouble with this one. I tried following the source code on the example below, but I cannot get it to work even with the direct source code.

I am using the script found here: https://github.com/aehlke/tag-it/blob/master/README.markdown

Here is the javascript that is initializing the tag-it library in the header:

$(function() {
    $('#skills').tagit({     
        singleField: true,
    });
});

And here is the <ul> element that is supposed to turn into an input field when the tag-it.js library is called:

<ul id="skills"></ul>

I am including all these files to get this to work:

<link rel="stylesheet" href="styles/tag-it.css">
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/flick/jquery-ui.css">

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js"></script>
<script type="text/javascript" src="js/tag-it.js"></script> 

All the files are being called correctly and I am not receiving any errors. There is NO input form where the <ul> tags are unless I create one manually

Does anyone have a clue as to why this isn't working? Do I need to manually add an input field and assign a specific ID or class to it?

EDIT: This has been solved. The code posted is all 100% correct, I had an error in the jquery selector before tag-it initialization.

4

2 回答 2

1

这对我来说是个问题,我的模板有一个链接到本地​​ jquery 的脚本。因此,当我从 tagit 复制 jqueryui 和 jquery 链接时,它会重叠。摆脱本地 jquery 为我做到了。

于 2015-11-15T07:10:15.823 回答
0

我想问题出在那个逗号上

你放了

singleField: true,

但它必须是

singleField: true

如果您有两个选择,例如

tagSource: availableTags,
singleField: true

那么只有第一个选项有逗号 第二个或最后一个选项(如果有超过 2 个选项)将没有逗号

于 2013-01-30T13:31:55.410 回答