Code Monkey home page Code Monkey logo

tagmanager's Introduction

A jQuery plugin to create tag input fields, which works nicely with Twitter Typeahead.js and Twitter Bootstrap

See a demo and read all the documentation at http://welldonethings.com/tags/manager/v3.

The documentation is automatically synced from Github, so if you'd like to make a correction please modify /docs/docs.html and raise a pull request.

Quick Start

Clone the repo, git clone https://github.com/max-favilli/tagmanager.git, or download the latest release.

Reporting Issues

  • Please report issues on our Github Issue Tracker.
  • In your report, please provide a jsfiddle (preferred), gist, or pasted HTML/JS with steps to reproduce the issue.
  • Before reporting:
    • Make sure you are using the latest master JS and CSS.
    • Check the documentation and existing open issues.
  • Issues which we are unable to reproduce or without activity after a few weeks will be closed.
  • Pull requests, documentation requests, and enhancement ideas are welcome.

Package Management Tools

We include the required files to use third-party package management tools in our repo. We rely on the community to help maintain these files, as the authors of this plugin do not use these tools. If you notice any issue with these or would like to add support for a new package manager, please raise a Pull Request.

  • Nuget: PM> Install-Package Bootstrap-tagmanager
  • Bower
  • Composer (PHP)
  • package.json (node.js)
  • TypeScript

Authors

Max Favilli

Johnny Shields (v 2.4.0+)

Special Thanks

The initial development of Tags Manager was funded by (now defunct) LogMyMoney.com, a simple online personal finance tool.

Copyright and License

Copyright 2012 MaxFavilli.com

Licensed under the Mozilla Public License, Version 2.0 You may not use this work except in compliance with the License.

tagmanager's People

Contributors

ajeliuc avatar apperception avatar auxbuss avatar bryanrice800 avatar chkwok avatar cliffordwhansen avatar coffeeaddict avatar doppiojp avatar dric avatar fogs avatar glendel avatar henryoswald avatar hhaidar avatar hmvs avatar intuxicated avatar johnnyshields avatar keshin avatar leonidaz avatar lukel99 avatar matsu911 avatar max-favilli avatar michalsvec avatar santoshs avatar stalinb87 avatar sumegizoltan73 avatar sveracarrasco avatar totymedli avatar troex avatar yohn avatar zkwentz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tagmanager's Issues

Add Support for Differentiating Between Tag Value/ID and Display Name

I would like to utilize this plugin for a user selection field.

Say I have a users table that maps an ID to non-unique names (e.g. John Doe). As it is, if I wanted to search by the user's name, this plugin would post the name upon form submission. Ideally, it would be great if support were added to retrieve and post the ID for the entries instead of the display values.

So, typeaheadAjaxSource should produce JSON similar to that below:

{"tags":[{"tag":"Pisa", "id":1},{"tag":"Rome", "id":2},{"tag":"Milan", "id":3},{"tag":"Florence", "id":4},{"tag":"New York", "id":5},{"tag":"Paris", "id":6},{"tag":"Berlin", "id":7},{"tag":"London", "id":8},{"tag":"Madrid", "id":9}]}

The value of the tag attribute is displayed, while the value of the id attribute is actually submitted.

keyup event problem with delimiter code 44

You bind keyup to catch delimiters, what ever my layout is when I press key where comma is keyup fires event with code 44. The problem is that in Cyrillic/Russian keyboards we have symbol б (b symbol) on that key.
http://www.terena.org/activities/multiling/ml-mua/test/img/kbd_russian.gif

So it makes impossible to enter any word with than symbol because tagsManager triggers pushTag event, I assume keypress event instead must be used. I'm sure this issue isn't limited to Russian language, CJK inputs probably have the same issue.

Yes I still can set another delimiters but I want to be able to use commas as well.

@wellBackground variable undefined in the .less file

With the lates bootstrap.less file included I get this error in the browser:

variable @wellBackground is undefined
in bootstrap-tagmanager.less on line 6, column 38:
.myTag {
background: none repeat scroll 0 0 @wellBackground;
border: 1px solid @linkColor;

I checked the Twitter Bootstrap customization page and indeed there's no @wellBackground variable.

Keyboard navigation in Opera

I've just tried your demo using Opera 12.14 and if I type a single character and get a list of a few options in the dropdown it doesn't let me use the keyboard (pressing down arrow) to move between options in the dropdown.

This functionality works in the bootstrap typeahead demo on http://twitter.github.com/bootstrap/javascript.html#typeahead and your demo works in Chrome but not for me in Opera.

Is this a bug or just something that has been fixed in the latest version of bootstrap typeahead?

Thanks

Removing the hidden field if it exists

Great plugin, I've adopted it to Roadkill .NET wiki as its new tag manager.

I've got a small suggestion which I've added to our version of the plugin: if the hidden field already exists, then it's removed in the setup.

To do this I added these lines to line 344:

        var hiddenTag = $("input[name=" + tagManagerOptions.hiddenTagListName + "]");
        if (hiddenTag.length > 0)
        {
            hiddenTag.remove();
        }

Pretty simple, but ensures that your page/tag hidden field can be used inside smoke tests frameworks that don't have Javascript enabled.

Regards
Chris

Typehead is not working

I'm using the tag manager with the typeahead enabled and it's not working. The typeahead list does not appear at all.

Tags only break line upon spaces in tag names. Otherwise, the row is infinite.

When you insert tags without any space in the tag name, the row of tags never ends, thus tags go out of "spans" or "wells". They only break a new line if there is a space in the name of a given tag.

The solution is very simple. Just add:

display: block;
float: left;

to the .myTag{} in the css file.

Congratulations for this bootstrap plugin!

Latest bootstrap breaks typeahead functionality

The format of bootstrap's typeahead has changed and I believe this has broken tagmanager's typeahead functionality. I'm not entirely sure as I'm new to tagmanager, and the docs don't provide an example of usage.

What I have is:

$("#user_tags").tagsManager({
  prefilled: #{tags},
  preventSubmitOnEnter: true,
  backspace: [],
  CapitalizeFirstLetter: true,
  maxTags: 3,
  typeahead: true,
});

That all works fine apart from typeahead. To populate, I am trying:

$("#user_tags").typeahead({
  source: function(query, process) {
    $.get('/#{@user.uname}/tags', { query: query, limit: 4 }, function(data) {
      return process(data);
    });
  }
});

This, or similar, works fine for other cases, but for tagmanager, even the ajax get is not being invoked.

Hidden field strategy

I was this close pinches fingers together real tight to making a pull-request for #3 that, but I realized there is another issue with the hidden tag list.

I'm using this with Rails, and with Rails you can use the query string so that : ?tags[]=one&tags[]=two&tags[]=three turns into a neat array (accessible through param[:tags]) so it might be nice to have a second strategy, so that each tag has it's own hidden-field.

Sounds trivial - is not, and since it requires a bit of a rewrite, I would like your opinion on this, @max-favilli

Delimeters Not Working

With the following setup options, no new tag is created when hitting the comma (",") when typing tags in the associated input field.

var skillsOptions = {
backspace: [],
CapitalizeFirstLetter: false,
typeahead: true,
typeaheadSource: ['Tag1','Tag2','Tag3'],
delimeters: [188, 13],
tagClass: 'label',
tagsContainer: '#skillTagsContainer',
hiddenTagListName: 'skills',
preventSubmitOnEnter: true
}

Best Regards,

Marc

Removing tag navigates away from the current page

When clicking the X to remove a tag and used in conjunction with the < base > tag, the page gets reloaded to the base URL. In order to avoid this, you could use jQuery's prevent default in line 211

....
jQuery("#myRemover_" + TagId).on("click", obj, function (e) {
            e.preventDefault(); //add this line
            var TagIdToRemove = parseInt(jQuery(this).attr("TagIdToRemove"));

....

Documentation: AjaxPushAllTags undocumented

Without reading the source code, it would appear that there is no way to push a new list of tags after a tag is removed.

Adding AjaxPushAllTags to the documentation (blog) would resolve this.

Double tags created when using enter from typeahead list

To reproduce:

  • scroll through a typeahead dropdown list with the cursor keys
  • hit enter on a selected item

Two tags are created. The first will be the typed characters. The second will be the selected item from the dropdown. If maxTags is set, then only the first tag is created should the second be greater than maxTags.

enter to add tag not working

When i try to add a tag, and press enter istead of comma, the tag is not being added. I tried to disable all my javascript and the same thing happened. Also tried to remove the delimiter option.

$(".productTagManager").tagsManager({
    CapitalizeFirstLetter: true,
    preventSubmitOnEnter: true,
    typeahead: true,
    typeaheadAjaxPolling: true,
    typeaheadAjaxSource: '/system/ajax/produtoTags.php',
    blinkBGColor_1: '#FFFF9C',
    blinkBGColor_2: '#CDE69C',
    hiddenTagListName: 'productTag',
});

Register custom events or improve ajax save options

Maybe I've missed something, but is there a way to save the tags information back to the server with ajax besides the ajaxpush option? Your option sends a new tag each time it's added but I don't see any logic to inform the server of a deleted tag.

For our own copies I simply added a custom event to the refreshHiddenTagList method:

obj.trigger('tags:refresh', tlis.join(","));

Then in our scripts I listen for it and save the entire batch of tags to the server. This let's me wipe the old tags and save the new ones, which takes care of deleted tags.

$('.tagManager').on('tags:refresh', function(e,tagstring){
    $.post('/our/url', {tags:tagstring});
});

jQuery 1.9.1 error

I'm using the plugin without any options:
$("#tags").tagsManager();

Unfortunately jQuery gives a general error:
TypeError: e is undefined

I'm using jQuery 1.9.1. Is this component ready for that version?

Comment period open for new tag manager specification

My research into tag managers led me to this project. I rewrote it and was about to rewrite it based on my first rewrite when I decided it would be better to let the community develop this together.

So, in support of this effort there is a new development site
http://tagmanager-tomanderson.rhcloud.com/

The new repository is
https://github.com/TomHAnderson/tagmanager

Currently the project is soliciting input from the community on the functional specifications of the tag manager.

Thanks,

Tom

tagsContainer option doesn't work with .tagsManager('pushTag', 'I_am_a_new_tag') method

I turned an input field into a tags manager with "tagsContainer" using this command:
$(".tagManager").tagsManager({tagsContainer: "#my-tags-container"});

Once tagsManager has been created, I want to push some new tags via pushTag method: "$(".tagManager").tagsManager('pushTag','I_am_a_new_tag');". The problem here is new tags aren't added into "#my-tags-container" element, defined above. They are added into DOM using default behavior, it means with not container.

Help with hiddenTagListName

Hi,

I would like to add the name of the tagManager input field in the hiddenTagListName option, something like :

$('.tag_manager').tagsManager({
 hiddenTagListName: 'tag_'+$(this).attr('name')
});

But it doesn't work.

Is there an easy way of doing this ?

getting duplicates with prefilled tags

This plugin has a great feature preventing users from entering duplicate tags. However, when we give a list of tags via the "prefilled" attribute, it does not compare against that list and only takes in consideration the ones just entered.

Comma with Typeahead

Hi There,

I've been trying to fix this bug, but I'm not very experienced in js, and kinda running out of time.

When using typeahead, if the user types a comma while the suggestion box is present, the suggestion box disappears, but the comma stays in the input box and no tag is created. This is confusing since the user should always be able to use the comma to create a tag, with or without suggestions present. This allows tags with commas to be submitted.

A fix would be much appreciated!

P

[Edit: I see that it works as expected on the demo page. I'm not sure what would cause different behavior on my test site. Any ideas appreciated. ]

Escape special characters

I am using this great plugin with Ruby on Rails
And in Rails there are quite a lot of name are like: user[skill_tags]

And it seems that you are generating ID for tags from name
Which makes it like this: user[skill_tags]_0

Now I am using a custom name for that input, no big trouble
But it would better to escape those characters, since by spec they are forbidden

More about selector:
http://api.jquery.com/category/selectors/

Thanks in advance :)
Pika~

tags not working fine

writing "it[enter]" will get the gat "italy" as espected, but also tag "it". (on demo page)

The name of the hidden input tag is not hiddenTagList (as described in the documentation on the website)

I was using the following input tag to implement tag management:

As stated in the documentation I should geet something like this for the hidden input tag:

... but I get something like this:

As you can see, the name of the hidden input tag it's "hidden-idea_tags", it's basically "hidden-" concatenated with the name of the other input tag.

I can leave with that, and maybe it's better this way, but in that case the documention must be updated.

IE8: Object doesn't support this property or method

Works great in Chrome, but IE8 (that we are forced to use at work) throws the following error:
"Message: Object doesn't support this property or method
Line: 246
Char: 7
Code: 0
"

My code:
$(function() {
$(".tagManager").tagsManager({
CapitalizeFirstLetter: true,
preventSubmitOnEnter: true,
delimeters: [44, 188, 13],
backspace: [],
prefilled: [ "Tag 1", "Tag 2", "Tag 3", "Tag 4" ],
hiddenTagListName: 'hiddenTagListA'

  });

});

Hidden tag selector should use quotes around name

If the name of the hidden input fields contains punctuation characters, such as a field named "report.tags", the selector used to check for its existence causes a JS error.

This can be fixed if the selector includes a pair of double quotes around the name:

  •    var hiddenTag = $("input[name=" + tagManagerOptions.hiddenTagListName + "]");
    
  •    var hiddenTag = $('input[name="' + tagManagerOptions.hiddenTagListName + '"]');
    

Thanks for this useful tool!

-- Simon

IE8: Object doesn't support this property or method (Line: 284, Char 13)

Hi there!

I tried to use the latest version from github, but I get this error with IE8:

"Message: Object doesn't support this property or method
Line: 284
Char: 13
Code: 0
"

My code:
$('input[data-imagename="'+responseJSON.uploadName+'"]').tagsManager({
typeahead: true,
typeaheadAjaxSource: '../../index.php?ep_function=get_global_tags',
blinkBGColor_1: '#FFFF9C',
blinkBGColor_2: '#CDE69C',
maxTags: 5,
hiddenTagListName: 'hiddenTagList_'+filename[0],
validator : function(tag) {
if(tag.match(/^([\w\s]|[öÖüÜäÄß'*#.+&$]){2,30}$/gi).length>0) {
return true;
}
else
return false;
}
});

Does anyone know how to fix it? Thanks in advance.

Clicking outside the dropdown causes selected tag to be appended

Steps to reproduce:

  • Enter text, drop down appears and first item is auto-selected
  • Click outside the dropdown window
  • Selected word is appended to the tag list

What should happen:

The dropdown should be closed and the word not appended to the tag list. Similar to pressing escape.

Ajax polling doesn't contain typeahead text

When typing with polling on the same request gets made lots of times.

I've modified ajaxPolling to send the user input to the typeaheadAjaxSource,

var ajaxPolling = function (query, process) {
var user_input = jQuery(obj).val();
user_input = trimTag(user_input);

  jQuery.ajax({
      url: tagManagerOptions.typeaheadAjaxSource, 
      dataType: 'json',
      success: function (data) {
                var sourceAjaxArray = [];
                if (data != undefined && data.tags != undefined) {
                  sourceAjaxArray.length = 0;
                  jQuery.each(data.tags, function (key, val) {
                    var a = 1;
                    sourceAjaxArray.push(val.tag);
                  });
                  process(sourceAjaxArray);
                };
              },
       data: {typeahead:user_input},
       method: 'POST'
  });
};

How to reset tagmanager

I'm using tagmanager on a bootstrap modal, I'd like to reset the tagmanager each time the modal is displayed.

What's the best way to reset the tagmanager?

Doesn't play nice with bootstrap modal dialog

When I open bootstrap dialog and init tagsManager it shows behind the dialog, default modal z-index is 1050, but setting higher z-index is not a hack, better if typeahead would be added after input field and not to the end on the document body

typeaheadAjaxSource and typeaheadAjaxPolling

I want the text in the input put yo be sent to my typeaheadAjaxSource. What do I need to do. I can not see that I am sending anything. No data in PHP's $_GET nor $_POST.

Can you help?

SMALL BUG REGARDING: "blinkBGColor_1 & blinkBGColor_2" animation

SMALL BUG REGARDING: "blinkBGColor_1 & blinkBGColor_2. When a duplicate tag is entered the user is notified with a blinking of the corresponding (duplicate) tag, here you can configure the colors." This doesn't work as is, I changed line 202 from this jQuery(objName + "" + pTagId).stop() to this: jQuery("#" + objName + "" + pTagId).stop(), and also added this script tag to my html page to get the background animation to work: src="//code.jquery.com/color/jquery.color-git.js"

option to name "hiddenTagList" differently per each instance

great plugin that actually works :)

the only thing that I noticed is that you're naming the hidden field with the same name for every instance "hiddenTagList". i would recommend to have this as an option and let users define what the name should be per instance, defaulting to "hiddenTagList"

Documentation: Multiple instances need unique names, not just unique ID's.

It's probably worth mentioning in the documentation (blog) that if you are going to have multiple instances of tag manager on a page, each input field must have a unique name, not just a unique ID.

If the fields aren't given a unique name popTag() always removes from the first instance, causing one to scratch one's head.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.