GithubHelp home page GithubHelp logo

yaireo / tagify Goto Github PK

View Code? Open in Web Editor NEW
3.3K 20.0 425.0 10.67 MB

๐Ÿ”– lightweight, efficient Tags input component in Vanilla JS / React / Angular / Vue

Home Page: https://yaireo.github.io/tagify/

License: Other

JavaScript 42.48% HTML 53.55% SCSS 3.97%
tagging html input tags tagify javascript react reactjs react-component angular-component

tagify's Issues

Add limit of tags

Another (hopefully small) feature what I thought would be nice (for me needed, lol):

Add possibility to limit the amount of tags.

So, basically, once you hit a certain amount (for example 4), it won't allow you to add any more tags.

I hope I am not becoming annoying here :)!

duplicate setting and event not working

I am using following code to prevent from getting duplicate values but neither console log is working nor duplicate true setting.

jQuery(document).ready(function($) {
		$("#tags").tagify({
			delimiters: ",",
			enforeWhitelist: true,
			autocomplete: true,
			whitelist: ["foo", "bar", "foo bar"],
			suggestionsMinChars: 1,
			duplicates: true,
		}).on("duplicate", function(e, tagName) {
			console.log("duplicate" + e + " " + tagName);
		});
});

Auto release to npm on new git tag

I have installed tagify from npm and I relaized there is an old version on npm.

Maybe it would be a good idea to autorelease new git tags into npm

Any reason why it's not using normal HTML markup?

I found this from the StackOverflow question, and I think it really is the best plugin for tagging out of the list.

But why is it not using normal HTML elements? I think that would make this plugin perfect.

Autocomplete related issues/fixes

Currently, I have an issue where I have around 330 whitelisted items. Issue what it has is when it loads all together at once when I started typing, the browser becomes laggy. I don't have that shit computer, so I assume the most user would have the same issue. So, there is 2 recommendation, to add to autocomplete (or at least add a setting option for possibly support it!)

  1. Reduce the length of displaying all options and add a search bar to it. The search bar part should be an option not recommended, as if there aren't that many searchable options, it might become more pain, but having that option when whitelist is bigger, will help a lot! Below is example picture what another datatable plugin is using (Not tag support tho, ;))
    image
  2. Add option from when it will start autocompleting. Usually, it is the third character. This should be also an option, as if there are few characters, having it from first adds to the user experience. If you have however 330 whitelisted options, loading on the first character can be discouraging.

Also side note: That arrow what you disappeared actually destroyed a bit friendliness. I usually try to think that all clients are actual dumb-users and if they see box, but no way to open the option list, it can be confusing to them. It is not that huge of an issue to me, as I simply reversed the CSS file commit, but just a small thought I had.

Also, is it possible to donate for this project? I feel like you have done quite a lot, especially recently.

tagify.min.js is not synch with tagify.js

Hi, me again :)! I hope I am not getting annoying, as I truly think this is one of the best tagify libs out there. So I am suggesting things what makes sense, what are kinda needed in my current project and so on.

The first bug: Took me a while, when I didn't see that any updated weren't synching. Apparently, min.js is not same as just js. For an example that auto-add tag doesn't work there. Else, awesome job!

Bootstrap 4 Support

How can i use this Plugin / Javscript with Bootstrap 4?
If i use the Bootstrap 4 Form-Controls i see the input twice. Have a look here

My HTML-Code looks this:

<fieldset class="form-group">
<label for="tags">Tags (Limit 5)</label>
<input name='tags' placeholder='write some tags' value='foo, bar, buzz' class="form-control">               
</fieldset>

But when i look into the generated code i see that the input will be transformed to a Element. So there comes the problem that i see the input twice i think.
How can i use it correctly with bootstrap 4? Can you help me? Or someone else?

Is there a way to add a tag by code?

Hello,

I don't see in demos if it is possible to add a tag by calling a method in javascript.
I tried this without success. Is there a way?

var elm= $('#myInput').tagify();
elm.addTag('myTag');

CSS issues

Not sure if it's related by bootstrap (since the demo works fine for me) but anyways, here is how the fresh setup looks like:

image

background doesn't work at all for tags. Probably caused by the opacity and z-index in the tags tag > div::before.

When I remove the z-index from it:

image

Then in the tags tag > div > span change the opacity to .9 to make it work:

image

If you set the opacity to 1 it will not work.

This is known behaviour when using animations + z-indexing.

Using latest Opera browser. Doesn't work in Chrome neither.

Whitelist support id and value!

This might be harder (and not sure if possible), but if you could add into a white list of arrays ($id => $label) or something similar would be cool.

That means: In tag lists, it will add and show a label, but when saved, the input will save/use the actual set id.

This is a necessary feature if this project is used in larger databases OR there are the possibility of two same name strings.

Max Suggestion to be displayed from whitelist && some unexpected behaviours!

Can you please implement a new setting parameter that allows us to set how many suggestion the whitelist should display?
if not that, a callback on the event "on change" would be good too to actually manually handle the whitelist and displaying a maximum number of results. basically something like this :

function(request, response) {
        var results = element.filter(myarray, request.term,maxSuggestions);
        response(results.slice(0, maxSuggestions));
    }

Also please release a pre-compiled version of this to be implemented on vanilla html without needing pre-processors.

Also to correctly display the input like it's supposed to be displayed in the demo i had to manually hide the element i "tagified", i think it should be integrated in the tagify() function itself to actually hide the element that will only hold the value.

Great job btw!

Wrong Brackets in readme page

The closing bracket at the whitelist row must go to end

tagify = new Tagify( input, {
    duplicates: true,
    whitelist: ['foo', 'bar']},
    callbacks: {
        add : onAddTag // calls an imaginary "onAddTag" function when a tag is added
    }
);

When I remove a tag the input element is deleted

Hi and thank you for the nice js lib.
I have run onto a problem;
When i remove a tag the hidden input element is removed from DOM.
The bug also happens at your live demo page.
Please see the following screenshots.
At the first screenshot I highlight the hidden input before taking any action and at the second screenshot I delete a tag, as you can see the input element is removed.
before removing tag
after removing tag

Make sure field is not empty

Hi,

How can I make sure the field is not empty ?
Html tag 'required' is not working anymore using tagify.

Thanks in advance,
Julien

Feature request: List of matching tags

May I suggest a new feature: A list of matching tags showing in a list while you type in a tag.

For example, you type in #j and the list shows 5 available tags containing a "j". Typing #jq and the list is limited to tags containing "jq". User may select one of the matching tags from the list.

Anway, nice work you did with tagify ๐Ÿ‘

Using keyboard to select whitelisted item in Firefox fails

Firefox 55.0.0.2 on Ubuntu

Using the most recent commit from the GitHub repo and the demo index.html.

  1. Type, "A#" to display two whitelisted suggestions
  2. Use the down arrow on the keyboard to select one of the suggestions
  3. Rather than the selected suggestion being added to the field, the typed letters ("A#") are added

The behaviour is as expected in Chromium 60 on Ubuntu. The behaviour is expected in both browsers if the mouse is used instead of the keyboard to select one of the suggestions.

I will look at this myself now but any suggestions welcome.

Add on remove/add tag event possibility to check if it passed whitelist or not

Right now, if you pass tag what isn't whitelisted, it still gets activated and then immediately removed. This basically means right now I have to do double work

  1. Add whitelist
  2. Check in function again if it is in whitelist.

If you function details, there could be a parameter: "Passed whitelist" related, would be cool and make life easier.

Safari issue

I am trying to use tagify in one of the pages to implement tags and auto-suggestions.
The problem I am facing in safari is that the suggestion dropdown comes with a plain html dropdown menu and also selecting a keyword from the list of suggestions does not create a tag. Not sure if this has been reported before, but I do not see it in the list of issues here.

Add destructor

I don't see a destroy method in this library. Do you have a recommended way of destroying ta tagify-ed element. Or at least removing the tags from it?

Vue usage?

Can I use this with Vue JS or do I need to use as a Vue component?

Destroy method causes TypeError

Thanks for making Tagify!

I'm trying to basically 'reset' tagify fairly often based upon new information grabbed from a database. When I do that, I want to essentially remove all the old tags and start from scratch OR add tags retrieved from the database.

I saw the new 'destroy' method, which I'm attempting to use like this:

tagify.destroy();
When I try that, I get the following error:

Error in event handler for (unknown): TypeError: Cannot read property 'destroy' of undefined

However, tagify is definitely defined as I can run the tagify.on('foo') event handlers and it's working very well in all other respects. I imagine I am using the destroy method incorrectly, but I'm not sure how. If someone could please provide an example with real code that would also be very helpful.

Thanks!

Jake

tags color

Tags color not working when we set background color for parent div or container.

For example:

<div style="background-color: black">
    <input type=text id="tg">
</div>

<script>
    var tag = document.getElementById("tg"),
        tagify1 = new Tagify(tag);
</script>

Always show suggestions list, or way to trigger showing the suggestion list

First of all, great job on the library. I love the design.

I have a short list of suggestions that I'd like to always show to the user. I set suggestionsMinChars to 0, but it seems the suggestion list is only triggered inside callbacks.onInput. It would be nice to have this as a custom event or method so we can manually trigger the suggestion list.

Alternatively, you could also add the functionality that if suggestionsMinChars is 0, the suggestion list is shown as soon as the input gets focus.

Programmatically reset input

Hello guy!

First of all, congratulations for you lib. In my opinion, it's simple and easy to use as all lib should be!

What I am trying to do and I am not being able is to reset the input after form to be successfully sent. I have a single page application, so my page will not reload after form submit. Looking your code, I have tried the following solution:

// In my angular directive I store all tags in an array called "tags"
scope.reset = function(){
  for (var i = 0; i < tags.length; i++)
    tagify.removeTag(i); // tagify is the instance of your component
};

So, I run this code after form submit. However, just some tags got removed. Other ones are still there and I couldn't understand why... ๐Ÿค”

Could you help me?

UPDATE
As workaround, I have solved it destroying and intantiating the component again. Working fine.

Object doesn't support property or method 'findIndex'

Hello,

I have the following error on IE11
"Object doesn't support property or method 'findIndex'"

In the following line in jquery.tagify.min.js
function(t){var e=this.value.findIndex(function(e){return t.toLowerCase()===e.toLowerCase()}

It's seem that IE11 doesn't support findIndex
https://stackoverflow.com/questions/41938036/object-doesnt-support-property-or-method-findindex-ie11-javascript-issue

Maybe you do not support IE11?

Thx in advance

Ajax

Please can I use ajax auto complete with this?

Allow pull request

Please allow pull request, I added a little feature and want to share it!
Thanks!

Only numbers input?

Hi, I have a question about this ...
the plugin has option input only numbers?

how to add other delimiter, because my project need use "," and " " (comma and spacebar) ????

sincerily
MMR

duplicates option not working !

hi . i'm try to set duplicates option to false but Still typing duplicates values is enable.
can you fix this issue please ?

Extra space after comma

Hi,

Great Plugin ! Only drawback is that it adds an extra space after every comma, so the output list will look something like : test, test1.
Could it be possible to add an option so it would be : test,test1 ?

Thanks in advance for your help,
Julien

Event not triggering (?)

Hello, I have this piece of code

$('.tagify').each(function () {

            var $toTagify = $(this);

            $toTagify.tagify({

                duplicates : false

            });
            
            $toTagify.on('add', function (e) {
                console.log(e);
                console.log("test");
            });

        });

but the events are not triggering. Am I wrong or there's something that doesn't work properly?

Updated Bower version?

Would it be possible to tag a new version so that the latest code can be used with Bower? I see that Bower config is on v1.0.5 while NPM is v1.1.0. Looks like the latest version has some improvements we'd like to use.

Remote content

Just need to know if the tags can be fetched via ajax

ID => Value tags

Hi,

Can the plugin support an array of key => value as tag ?
I mean something like that : <tag data-id="1">...</tag>

I use the plugin with an user system and filtering users with name is not that good.

Thanks :)

Autocomplete/Whitelist behavior on select

Hi,

When using autocomplete & whitelist options, if you select an option from the list, it does not add it as a tag. You need to press enter.

Select
capture d ecran 2018-02-02 a 18 30 34
Result
capture d ecran 2018-02-02 a 18 30 40

Normal ?

Adding tag programmatically

Hi

I know I can add tags when rendering the tagify component, like so:

<input name='user-tag' value='apple, orange, banana'>

But in my case, I have a service which returns tags to show, but unfortunately this returns after the tagify component has been rendered. So I would need to add the tags later programmatically, like

$('[name=user-tag]').Tagify.addTag('kiwi');

But this is currently not possible. Can this feature of adding tags programmatically be implemented?

Thanks ๐Ÿ‘

When you autocomplete from whitelisted list, possibility to add it straight as tag

Right now when you search from lsit, you have to do double enter to add it into list. It is bad design, when I use whitelist only method and once person chooses from autocomplete list, they cannot change it anyway (will be denied straight away). So it would be good to add setting/option where selection from autocomplete will go straight into the tag list as approved tag.

Sidenote: Thank you for this up to date tagify. I like it a lot and if those last 2 quality updates will be added, would be cool! Right now there are million of tagify libraries, but this seemed easiest and best one by far.

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.