Home > jquery > jQuery Tag Editor 1.4

jQuery Tag Editor 1.4

A new version of jQuery Tag Editor is out. This time it’s up to version 1.4 and gladly enough I didn’t have to put almost any work into it. A huge thanks goes out go to Joost Elfering who made most of the changes and improvements in this release.

As usual, the demo and project page can be found at the urls below.

http://blog.crazybeavers.se/wp-content/Demos/jquery.tag.editor/
http://plugins.jquery.com/project/jQueryTagEditor

Categories: jquery Tags: ,
  1. Tomas
    June 11th, 2010 at 21:20 | #1

    Great work guys, I like it!

    I have one problem though. I am trying to make tagEditor to work with jQuery UI autocomplete and I can’t get it working. It adds tag multiple times when selected using autocomplete box. When I add tag manually it works fine. Here is my code:

    $(“#id_tags”).tagEditor(
    {
    items: [],
    confirmRemoval: true,
    completeOnSeparator: true,
    continuousOutputBuild: true
    });
    $(“#id_tags”).autocomplete(
    { source:’{% url tags %}’,
    minChars: 2 ,
    select: function(event, ui) {
    $(“#id_tags”).tagEditorAddTag(ui.item.value);
    $(“#id_tags”).val(”);
    return false;
    }
    }
    );

    I use jQuery 1.4.2 and UI 1.8.2.

    Thanks a lot,

    Tomas

  2. August 9th, 2010 at 13:47 | #2

    Contribution (bug/improvement): less code + tag uniqueness
    current version : 1.4(.1 the same bug)
    if you tape twice the same tag in the input (e.g. ” tag1, tag2, tag1″), you will add 3 tags and not 2 tags. To correct this misbehavior,
    Add:
    in the addTag function
    for (var i = 0; i itemBase.push(tag);

    Remove
    in the function buildArray() {
    <== for (var i = 0; i < items.length; i++) {
    <== itemBase.push(jQuery.trim(jQuery(items[i]).text()));
    < == }

    best,
    nicolas maisonneuve

  3. August 9th, 2010 at 15:24 | #3

    (oups, forget the remove step, it’s a mistake)
    nicolas

  4. August 31st, 2010 at 09:53 | #4

    When using multiple input fields in one page, is there a way to use a Get Tags button for each one?

    Pressing Get Tags button 1 will extract the results entered from input 1
    Pressing Get Tags button 2 will extract the results entered from input 2
    and so on…

  5. Rene van den Berg
    September 1st, 2010 at 16:48 | #5

    I’ve created a small patch that allows generating events when the tags are changed (added or removed). The patch needs some manual work, since it’s based on a slightly older version of the tag-editor code. The event carries a serialized version of the currently selected tags.

    diff –git a/public/javascripts/plugins/jquery.tag.editor.js b/public/javascripts/plugins/jquery.tag.editor.js
    @@ -165,7 +165,13 @@
    itemBase.push($.trim($(items[i]).text()));
    }
    if (options.continuousOutputBuild) {
    + var oldVal = hiddenText.val();
    hiddenText.val(itemBase.join(options.separator));
    + if (oldVal != hiddenText.val()) {
    + hiddenText.trigger(“tagsChanged”, {
    + tags : hiddenText.val()
    + });
    + }
    }
    }

  6. September 26th, 2010 at 13:56 | #6

    I’m not sure is it bugs?

    In Demo 3 Example (http://blog.crazybeavers.se/wp-content/demos/jquery.tag.editor/)
    First push on button Set Tag, it will push a new tag, then when i’m push a first button (Get Tag) it doesn’t show a newly tag that pushed before?

  7. October 28th, 2010 at 07:21 | #7

    At line 116 I added

    if (options.cssPrefix)
    item.attr(‘class’, options.cssPrefix + tag.replace(‘ ‘, ‘_’));

    This puts a class attribute on the element if there is a cssPrefix option (which of cause is added up the top) there for when the user “hits” on tags that are know can highlight them. ie

    $(“#tags”).tagEditor({cssPrefix:’tagItem’});

    ..

    .tagItemRed {background-color:red;}

    When the user add a “Red” tag the the tag will be displayed with a Red background.

    Hope this helps.

  8. Herman
    July 16th, 2011 at 16:49 | #8

    Hi,

    When txtbox is empty and hit Add Tag it’s not add in the tag in the ul list, as well how to make the tags parse back to asp.net page, so back-end code able to read all the value.

    Regards,
    Herman

  9. July 16th, 2011 at 22:02 | #9

    @Herman
    Hi Herman,

    If the textbox is empty then no tag should be added since there it nothing to add.

    About the ASP.Net issue I’m afraid I don’t really know why it fails right now. I’ve given up on webforms a long time ago for ASP.Net MVC (which works perfectly with the tag editor).

    / Karl

  1. May 30th, 2010 at 07:48 | #1