EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: devnull on May 10, 2016, 04:43:35 AM



Title: detecting user vs form load() events
Post by: devnull on May 10, 2016, 04:43:35 AM
Is it possible, for any element / object, to detect whether the value was changed / selected by a form load or by a user click / select ?

Thanks


Title: Re: detecting user vs form load() events
Post by: stworthy on May 10, 2016, 11:49:41 PM
Set a 'changedByLoad' property value to indicate what triggers the 'onChange' event. Please refer to the code below:
Code:
$(function(){
$('#ff').form({
onChange: function(t){
var opts = $(this).form('options');
if (opts.changedByLoad){
console.log(t);
console.log('changedByLoad')
}
},
onLoadSuccess:function(){
var opts = $(this).form('options');
opts.changedByLoad = false;
}
});
var loadForm = $.fn.form.methods.load;
$.extend($.fn.form.methods, {
load: function(jq, param){
return jq.each(function(){
var opts = $(this).form('options');
opts.changedByLoad = true;
loadForm($(this), param);
});
}
});
})