EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Stefan B. on September 30, 2014, 06:00:49 AM



Title: Different between form('reset') and form('clear') ?
Post by: Stefan B. on September 30, 2014, 06:00:49 AM
Hello, I have a question:

What is the different between form('reset') and form('clear') ?


Title: Re: Different between form('reset') and form('clear') ?
Post by: jarry on September 30, 2014, 07:46:22 AM
The 'reset' method resets the fields to their original values. The 'clear' method only clears the values of the fields.


Title: Re: Different between form('reset') and form('clear') ?
Post by: Stefan B. on January 12, 2015, 08:18:23 AM
Hi. What you mean with "original values" ?

1) We get the form data from remote server.
2) Changing some form fields
3) Then we call
Code:
$('#formId').form('reset');
to reset the data to the original data before changing. But after that all form fields are emty! No values shown!

Is this a bug?


Title: Re: Different between form('reset') and form('clear') ?
Post by: jarry on January 12, 2015, 08:37:48 AM
The original value is the initialized value when created the component.
Code:
$('#t1').textbox({
  value: 'v1'
});
The code above create a textbox with 'value' set to 'v1', its original value is also set to 'v1'. After calling 'reset' method, the textbox's value will be set to 'v1' even if the user enters other value.


Title: Re: Different between form('reset') and form('clear') ?
Post by: devnull on May 04, 2015, 09:59:20 PM
FYI - this works if the value attribute is hard-coded into the page before easyui executes:

Code:
<input id="myinput1" value="123">


But if you add the value attribute programmatically then you need to update the eui object:

Code:
<input id="myinput2">
$('#myinput2').textbox('options').originalValue = "123";