【问题标题】:jQuery tag-it, how to execute post when item removedjQuery tag-it,删除项目时如何执行发布
【发布时间】:2011-12-04 22:19:07
【问题描述】:

我使用的是 jQuery Tag-It 脚本,可以在这里查看:

http://levycarneiro.com/projects/tag-it/example.html

该脚本最初不附带发送添加标签的帖子或删除用户删除的标签的选项。

我成功地将 post 请求添加到 php 脚本中,这样当有人添加标签时,它会将其插入数据库中。

问题是,当有人单击“x”按钮删除其中一个标签时,我似乎无法找到获取实际标签值的方法..

【问题讨论】:

    标签: javascript jquery tags tag-it


    【解决方案1】:

    这是修改后的代码,因此您可以访问被删除的标签..

    click 处理程序中(x

    if (e.target.tagName == 'A') {
                // Removes a tag when the little 'x' is clicked.
                // Event is binded to the UL, otherwise a new tag (LI > A) wouldn't have this event attached to it.
                var tag = $(e.target).parent();
                //console.log( tag.children('input').val() ); // this line extracts the tag value
                tag.remove();
            }
    

    并在keypress 处理程序中使用

    if (tag_input.val() == "") {
                    // When backspace is pressed, the last tag is deleted.
                    var tag = $(el).children(".tagit-choice:last");
                    // console.log( tag.children('input').val() ); // this line extracts the tag value
                    tag.remove();
                }
    

    演示地址 http://jsfiddle.net/gaby/yYHTu/1/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-14
      相关资源
      最近更新 更多