EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: samuel.fung on April 10, 2017, 06:38:42 PM



Title: tagbox get remaining text
Post by: samuel.fung on April 10, 2017, 06:38:42 PM
How to get the words that has not become a tag (i.e. not yet press enter)?

(https://www.jeasyui.com/forum/index.php?action=dlattach;topic=6610.0;attach=1453)
$(...).tagbox("getValues") will return "apple" and "orange"; "banana" is excluded.

Alternatively, when the tagbox lose focus, is there any way to auto forming remaining text into a tag?


Title: Re: tagbox get remaining text
Post by: stworthy on April 10, 2017, 11:44:43 PM
Please attach a 'blur' event handler to the inputing box, retrieve the inputing text and append it to the values.
Code:
$('#tb').tagbox({
inputEvents: $.extend({}, $.fn.tagbox.defaults.inputEvents, {
blur: function(e){
var target = e.data.target;
var text = $(target).tagbox('getText');
if (text){
var values = $(target).tagbox('getValues');
values.push(text);
$(target).tagbox('setValues', values);
}
}
})
})


Title: Re: tagbox get remaining text
Post by: samuel.fung on April 11, 2017, 12:56:02 AM
Wonderful, thank you.

Another question: I would like to use tagbox in property grid. It works fine except the "required" validation. The tags are not recognized as input value.

(https://www.jeasyui.com/forum/index.php?action=dlattach;topic=6610.0;attach=1458)

Code:
$.extend($.fn.datagrid.defaults.editors, {
    tagbox: {
        init: function(container, options){
            var input = $('<input type="text">').appendTo(container);
            return input.tagbox(options);
        },
        destroy: function(target){
            $(target).tagbox('destroy');
        },
        getValue: function(target){
            return $(target).tagbox('getValues');
        },
        setValue: function(target, value){
            $(target).tagbox('setValues', value);
        },
        resize: function(target, width){
            $(target).tagbox('resize', width);
        }
    }
});

Code:
row.editor = {
    type: "tagbox",
    options: {required: true}
}


Title: Re: tagbox get remaining text
Post by: samuel.fung on April 11, 2017, 07:32:24 PM
I've posted the 2nd question in the bugs forum
https://www.jeasyui.com/forum/index.php?topic=6615