fix select bug
This commit is contained in:
parent
756252ccf0
commit
8fe18cedbc
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -147,14 +147,14 @@ layui.define('layer', function(exports){
|
|||||||
});
|
});
|
||||||
|
|
||||||
//检测值是否不属于select项
|
//检测值是否不属于select项
|
||||||
var notOption = function(value, callback, keyup){
|
var notOption = function(value, callback, origin){
|
||||||
var num = 0;
|
var num = 0;
|
||||||
layui.each(dds, function(){
|
layui.each(dds, function(){
|
||||||
var othis = $(this)
|
var othis = $(this)
|
||||||
,text = othis.text()
|
,text = othis.text()
|
||||||
,not = text.indexOf(value) === -1;
|
,not = text.indexOf(value) === -1;
|
||||||
if(value === '' || not) num++;
|
if(value === '' || (origin === 'blur') ? value !== text : not) num++;
|
||||||
keyup && othis[not ? 'addClass' : 'removeClass'](HIDE);
|
origin === 'keyup' && othis[not ? 'addClass' : 'removeClass'](HIDE);
|
||||||
});
|
});
|
||||||
var none = num === dds.length;
|
var none = num === dds.length;
|
||||||
return callback(none), none;
|
return callback(none), none;
|
||||||
@ -177,7 +177,7 @@ layui.define('layer', function(exports){
|
|||||||
} else {
|
} else {
|
||||||
dl.find('.'+NONE).remove();
|
dl.find('.'+NONE).remove();
|
||||||
}
|
}
|
||||||
}, true);
|
}, 'keyup');
|
||||||
|
|
||||||
if(value === ''){
|
if(value === ''){
|
||||||
dl.find('.'+NONE).remove();
|
dl.find('.'+NONE).remove();
|
||||||
@ -187,11 +187,13 @@ layui.define('layer', function(exports){
|
|||||||
input.on('keyup', search).on('blur', function(e){
|
input.on('keyup', search).on('blur', function(e){
|
||||||
thatInput = input;
|
thatInput = input;
|
||||||
initValue = dl.find('.'+THIS).html();
|
initValue = dl.find('.'+THIS).html();
|
||||||
notOption(input.val(), function(none){
|
setTimeout(function(){
|
||||||
if(none && !initValue){
|
notOption(input.val(), function(none){
|
||||||
input.val('');
|
if(none && !initValue){
|
||||||
}
|
input.val('');
|
||||||
});
|
}
|
||||||
|
}, 'blur');
|
||||||
|
}, 200);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user