EasyUI Forum
September 14, 2025, 04:13:20 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
  Home Help Search Login Register  
  Show Posts
Pages: [1]
1  General Category / EasyUI for jQuery / what's the difference between the same method of combobox and textbox on: October 26, 2016, 06:21:44 PM
I didn't learn jquery much befor start using jquery-easyui, so I can not understand the description below totaly.
ComboBox:
Extend from $.fn.combo.defaults. Override defaults with $.fn.combobox.defaults.
Combo:
Extend from $.fn.textbox.defaults. Override defaults with $.fn.combo.defaults.
TextBox:
Extend from $.fn.validatebox.defaults. Override defaults with $.fn.textbox.defaults.


so I have question:
There is a method "clear" of combobox, and a same method "clear" of combo/textbox too, what's the difference between them?

html:
Code:
<input id="cc" class="easyui-combobox" name="dept" data-options="valueField:'id',textField:'text',url:'get_data.php'">

js code1:
Code:
$('#cc').combobox('clear');

js code2:
Code:
$('#cc').textbox('clear');

code2 leads to the same result as code1, is code2 a recommended way? If there is just 1 <input> it's ok to write codes strictly in Documentation standard format.
But if there are 20 <input> elements with textbox or combobox or datebox classes together like this:
Code:
<form id="fm">
  <input id="a" class="easyui-combobox">
  <input id="b" class="easyui-combobox">
  <input id="c" class="easyui-textbox">
  <input id="d" class="easyui-textbox">
  <input id="e" class="easyui-datebox">
  <input id="f"  class="easyui-datebox">
  ... ...
</form
I want to clear their values and write codes like this:

js code1
Code:
$('#a').combobox('clear');
$('#b').combobox('clear');
$('#c').textbox('clear');
$('#d').textbox('clear');
$('#e').datebox('clear');
$('#f').datebox('clear');
... ...

or like this:
js code2:
Code:
$('#fm').children('input').each(function() {
  $(this).textbox('clear');
});

Code2 has much less lines, is there anything wrong or inappropriate with code2 which  leads to the same result as code1?
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!