E
E
ErickSkrauch2014-05-01 20:35:08
JavaScript
ErickSkrauch, 2014-05-01 20:35:08

How to fix a bug in the TagIt plugin?

This plugin is also used here on the Toaster, but there is no problem with the Russian letter "b".

Explanation
In English, the comma is where we have the letter "b". Since this script is a plugin for jQuery UI, the key codes (and not the characters themselves) are nailed to the ceiling with liquid nails and you will not prove anything to that jqui.

I came across this question, where it is explicitly stated that keypress is used, through which it is impossible to find out what kind of character is there, only the key code. But still, it somehow works on the Toaster.

Offtopic (villainy)
Да, я скачивал код с тостера, наглым образом автоформатировал его и пытался разобраться, но ничего путного у меня не вышло, так как на Тостере почему-то (такое ощущение), что плагин переписан примерно полностью через свои же события.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
personaljs, 2014-05-02
@personaljs

try this one

X
xfakehopex, 2014-07-14
@xfakehopex

try deleting this line) it helped me
c.which===b.ui.keyCode.COMMA&&!1===c.shiftKey||

I
Ivan Kashmir, 2014-11-21
@Kashmir2606

try it

this.tagInput.keydown(function (c) {
            if (c.which == b.ui.keyCode.BACKSPACE && "" === a.tagInput.val()) {
                var d = a._lastTag();
                !a.options.removeConfirmation || d.hasClass("remove") ? a.removeTag(d) : a.options.removeConfirmation && d.addClass("remove ui-state-highlight")
            } else a.options.removeConfirmation && a._lastTag().removeClass("remove ui-state-highlight");
            if (c.which === b.ui.keyCode.COMMA && !1 === c.shiftKey || c.which === b.ui.keyCode.ENTER || c.which ==
                b.ui.keyCode.TAB && "" !== a.tagInput.val() || c.which == b.ui.keyCode.SPACE && !0 !== a.options.allowSpaces && ('"' != b.trim(a.tagInput.val()).replace(/^s*/, "").charAt(0) || '"' == b.trim(a.tagInput.val()).charAt(0) && '"' == b.trim(a.tagInput.val()).charAt(b.trim(a.tagInput.val()).length - 1) && 0 !== b.trim(a.tagInput.val()).length - 1))c.which === b.ui.keyCode.ENTER && "" === a.tagInput.val() || c.preventDefault(), a.options.autocomplete.autoFocus && a.tagInput.data("autocomplete-open") || (a.tagInput.autocomplete("close"), a.createTag(a._cleanedInput()))
        }).blur(function (b) {
            a.tagInput.data("autocomplete-open") ||
            a.createTag(a._cleanedInput())
        });

change to
this.tagInput.keypress(function (n) {
            if (n.which === 44 || n.which === 13 || n.which === 47 || n.which == 32 && a.options.allowSpaces !== !0 && (b.trim(a.tagInput.val()).replace(/^s*/, "").charAt(0) != '"' || b.trim(a.tagInput.val()).charAt(0) == '"' && b.trim(a.tagInput.val()).charAt(b.trim(a.tagInput.val()).length - 1) == '"' && b.trim(a.tagInput.val()).length - 1 !== 0))(n.which !== 13 || a.tagInput.val() !== "") && n.preventDefault(), a.createTag(a._cleanedInput())
        }).keydown(function (n) {
            if (n.which == b.ui.keyCode.BACKSPACE && a.tagInput.val() === "") {
                var r = a._lastTag();
                !a.options.removeConfirmation || r.hasClass("remove") ? a.removeTag(r) : a.options.removeConfirmation && r.addClass("remove ui-state-highlight")
            } else a.options.removeConfirmation && a._lastTag().removeClass("remove ui-state-highlight");
            n.which == b.ui.keyCode.TAB && a.tagInput.val() !== "" && (n.which !== b.ui.keyCode.ENTER || a.tagInput.val() !== "", a.tagInput.data("autocomplete-open") || a.createTag(a._cleanedInput()))
        }).blur(function (e) {
            a.tagInput.data("autocomplete-open") || a.createTag(a._cleanedInput())
        });

works for me

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question