EasyUI Forum
May 20, 2024, 03:18:29 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: Validatebox - dynamically adding validtype  (Read 4035 times)
devnull
Sr. Member
****
Posts: 431


View Profile
« 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 ?
« Last Edit: November 30, 2015, 09:56:59 PM by devnull » Logged

-- Licensed User --
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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');
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!