jQuery标签编辑器功能
我正在使用 jQuery 标签编辑器 (http://blog.crazybeavers .se/wp-content/demos/jquery.tag.editor/)用于学校项目。一切都很完美,但我无法检索我添加的标签数组。这是我的代码:
$("#allTags").click(function () {
var tags = $("#tagEditor").tagEditor().getTags();
alert(tags);
});
数组不返回任何内容。
这是 jQuery 标签编辑器中的代码:
(function ($) {
$.fn.extend({
tagEditor: function (options) {
var defaults = {
separator: ',',
items: [],
className: 'tagEditor',
confirmRemoval: false,
confirmRemovalText: 'Do you really want to remove the tag?',
completeOnSeparator: false,
completeOnBlur: false,
initialParse: true
}
var options = $.extend(defaults, options);
var listBase, textBase = this, hiddenText;
var itemBase = [];
this.getTags = function () {
return itemBase.join(options.separator);
};
...
I'm using jQuery Tag Editor (http://blog.crazybeavers.se/wp-content/demos/jquery.tag.editor/) for a school project. Everything works perfect, but i'm not able to retrieve the array of tags that I added. This is my code:
$("#allTags").click(function () {
var tags = $("#tagEditor").tagEditor().getTags();
alert(tags);
});
The array doesn't return anything.
This is the code from the jQuery Tag Editor:
(function ($) {
$.fn.extend({
tagEditor: function (options) {
var defaults = {
separator: ',',
items: [],
className: 'tagEditor',
confirmRemoval: false,
confirmRemovalText: 'Do you really want to remove the tag?',
completeOnSeparator: false,
completeOnBlur: false,
initialParse: true
}
var options = $.extend(defaults, options);
var listBase, textBase = this, hiddenText;
var itemBase = [];
this.getTags = function () {
return itemBase.join(options.separator);
};
...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您仍然遇到问题,那么我建议您获取该插件的最新版本(从您上面提到的网站)。 getTags() 方法在最新版本中被重写,现在工作得更好了。
If you still have problems with this then I would recommend that you get the latest version of the plugin (from the site you mentioned above). The getTags()-method was rewritten in the latest version and works much better now.