EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: devnull on November 30, 2015, 09:30:50 PM



Title: Validatebox - dynamically adding validtype
Post by: devnull on November 30, 2015, 09:30:50 PM
I have a combobox that has a single validType set in HTML, then after loading I append other validTypes however only the one that was initially added through HTML appears to activate:

Code:
<input id="cbox" class="easyui-combobox" data-options="validType:'test1'">
var opt = $('#cbox').combobox('options');
if(!opt.validType) opt.validType = [];
else if(typeof opt.validType=='text) opt.validType = [opt.validType];
opt.validType.push('test2');

How can I get the object to reload the validType so that test2 is also activated ?


Title: Re: Validatebox - dynamically adding validtype
Post by: stworthy on November 30, 2015, 11:41:21 PM
Here is the extended method to set the 'validType' property for all the components inherited from textbox.
Code:
$.extend($.fn.textbox.methods, {
setValidType: function(jq, validType){
return jq.each(function(){
$(this).textbox('textbox').validatebox('options').validType = validType;
})
}
})

Usage example:
Code:
$('#cbox').combobox('setValidType', ['test1','test2']);
$('#cbox').combobox('validate');