-
Notifications
You must be signed in to change notification settings - Fork 439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
on "remove" event incompatibility with jquery #222
Comments
If that is the case I would suggest not using Tagify's jQuery version but to use vanilla tagify. Why does this matter you? what the actual bug? |
This is my workflow:
My Tagify events: add, remove, edit, every time any of those are called, the tags for the given file is updated. It's worth mentioning that i'm using this library as is, no customization of any form. The problem is: each time I "Empty Files Container" or "Close modal" that is a "destructive" operation, "removing" elements from DOM, it triggers the "remove" event bound to EVERY tag input, that means: if I have 1000 files listed, my server will receive 1000 tags update requests by closing a modal. I Tried renaming the "remove" event from your sources with no success. If you could point me to an example of having the same result I would gladly put to the test. Some code to clarify what I have: I've simplified the code as the logic is much more complex and won't be of use, so please give attention to the comments: PROBLEM ... function appendSearchResult($ctx,fileList) {
//-- Update file tags function
let fTags = function () {
//-- Gather tags on input and send to server by ajax
};
//-- Cleanup container
//-- PROBLEM (Calling empty will call 'remove' event on existing tagify objects)
$ctx.find('.fileResultContainer').empty();
//-- $html = Build HTML from fileList and parse with jQuery adding some validation events
//-- Create events on tag inputs
$html.find('input.fileTags').tagify().on('add', fTags).on('remove', fTags).on('edit', fTags);
$ctx.append($html);
}
function selectFile($file) {
//-- Gather file info and trigger callback function
//-- Close file search modal (bootstrap 4)
//-- PROBLEM (Calling "hide" will call 'remove' event on existing tagify objects)
$(this).parents('.modal').modal('hide');
} |
Digging up a little more, i found out that on "remove" is used by jQuery UI and it's triggered when an object is removed, so the Actual Bug is probably naming conflict, instead of just adding the 'remove' event from your library, it's also defining that when input is removed from dom, it should also call my function. My request is: is there a way to make it compatible without renaming your method (some kind of ".noConflict()" solution when extending jQuery with your library) or can you point me how to rename this event to: "tagRemoved" or something like that? |
But have you try not to use the jQuery version of Tagify? simply use Then the |
could you post an example for me, i'm very newbie on vanilla js events and selectors. |
Just don't use the jQuery version of Tagify but the normal version. switch the files. There are many examples in the README I will look just like your code now, only a slight different, just follow the guides, you'll understand it in no time |
Today i've taken some time to fix this on jQuery, for those who are bottered with the conflict with remove event from jQuery a simple solution is to rename the event on tagify as bellow:
|
you shouldn't modify the source code because I keep changing it and you will have to re-edit it every time I release a new version.. I will just make the fix in the code permanently and that's it. very soon I will releasing |
- do not add multiple after the last tag, in mixed-mode (happens if initial input value has multiline) - re-wrote "replaceTextWithNode" method completely and renamed it "replaceTextWithNode" - fix bug where unintended mixed-mode prefixes are removed instead of only the one needed - fix bug with mixed-mode dropdown not removed when Tagify de-focus - Changes to "autoComplete" setting. added "rightKey" sub-setting - when dropdown is shown, pressing ESC key should not create a new tag, but only hide the dropdown - improve the auto-comeplete setting with sub-settings for "enter" & "right" keys functionality (issue #103) - on fuzzy-search, only auto-complete the input with terms starts with the typed text - added loader animations to the CSS and "loading" method to Tagify - single-value select mode refactoring - demo page - suggestion list as tags that when clicked add the clicked tag - renamed jQuery event "remove" to "removeTag" #222 - make demo page header fixed to top - all triggered events return the instance's scope (tagify) - add methods to the README (replaceTag) - improved CSS dropdown animations (on show) - Show dropdown suggestions list on arrow down #333 - fixed #267 - Pasted text separated with new line symbol doesn't process correctly - fixed #356 - addTags not working on mix-mode - add boolean property to "this.dropdown" that would tell if the dropdown is shown or not - show suggestions dropdown when editing a tag - add event: "edit:keydown" - new event: "edit:input" - new event: "edit:change" - new event: "edit:start" - added dropdown ability to use css effects when showing - dropdown auto-adjusts its placement if there's no space for it at the bottom, it will flip to be above
Just released version |
When we have a tag input inside a container and we use:$('.container').empty(), it triggers the $ ('.tags').on('remove', ... ).
I believe that the name "remove" is conflicting with other similar events from jqueyr causing it to call tagify remove when it's not supposed to.
The text was updated successfully, but these errors were encountered: