EasyUI Forum
May 15, 2024, 04:40:48 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: tagbox get remaining text  (Read 6317 times)
samuel.fung
Newbie
*
Posts: 6


View Profile Email
« 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)?


$(...).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?
« Last Edit: April 10, 2017, 06:40:55 PM by samuel.fung » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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);
}
}
})
})
Logged
samuel.fung
Newbie
*
Posts: 6


View Profile Email
« Reply #2 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.



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}
}
Logged
samuel.fung
Newbie
*
Posts: 6


View Profile Email
« Reply #3 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
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!