EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: rezzonico on May 10, 2021, 06:54:55 AM



Title: prevent changes in a datebox field
Post by: rezzonico on May 10, 2021, 06:54:55 AM
Hi,

I need to prevent changes in a datebox field depending on the selected option in a confirmation message window.

In the following link select a new date and then select "Ok" on the confirmation message window.
Then select another date and then select "Cancel" on the confirmation message window.

http://195.144.40.170/jeasyui/AAA5/

As you can see the datebox is empty despite in my code there is the following line:
$('#dd').datebox('initValue', oldValue);

Any solution with onChange, onSelect, onBeforeSelect, ... is appreciated.

Regards
Miche


Title: Re: prevent changes in a datebox field
Post by: jarry on May 10, 2021, 07:52:16 PM
Please override the 'initValue' method of the datebox.
Code:
$.extend($.fn.datebox.methods, {
initValue: function(jq, value){
return jq.each(function(){
var opts = $(this).datebox('options');
if (value){
var date = opts.parser.call(this, value);
value = opts.formatter.call(this, date);
$(this).datebox('calendar').calendar('moveTo', date);
}
$(this).combo('initValue', value).combo('setText', value);
});
}
})

Or download a newer version of EasyUI from the site.


Title: Re: prevent changes in a datebox field
Post by: rezzonico on May 18, 2021, 07:15:45 AM
Thanks !

Regards
Miche