|
devnull
|
 |
« on: December 16, 2014, 03:47:49 AM » |
|
Is it possible to have an event trigger when any element in a form is changed whilst still maintaining the existing onChange() events which have already been binded to any input in the form ?
Thanks
|
|
|
|
« Last Edit: January 03, 2015, 05:18:23 PM by devnull »
|
Logged
|
-- Licensed User --
|
|
|
|
|
|
devnull
|
 |
« Reply #2 on: December 16, 2014, 07:42:13 PM » |
|
Wow ! thanks so much. I just included the js patch into the page (renamed to eui.form.onchange.js), but it does not appear to fire, is there anything else I need to do ?? <script src="js/jquery-easyui-1.4.1/jquery.easyui.min.js" type="text/javascript"> <script src="js/jquery-easyui-1.4.1/eui.form.onchange.js" type="text/javascript">
$.extend($.fn.form.defaults, {
onChange: function(target){ console.log(target); }
})
|
|
|
|
|
Logged
|
-- Licensed User --
|
|
|
|
jarry
|
 |
« Reply #3 on: December 16, 2014, 08:02:53 PM » |
|
Before using the 'onChange' event, you have to create the form component programmatically or add 'easyui-form' class to the <form> element.
|
|
|
|
|
Logged
|
|
|
|
|
devnull
|
 |
« Reply #4 on: December 16, 2014, 08:08:38 PM » |
|
Hi;
Thanks, yes I know that, I have several dozen pages all with forms that are working perfectly.
But what I am trying to achieve is to have some default action that will be taken unless a form has an override of the default setup.
Can this be done ?
|
|
|
|
« Last Edit: December 16, 2014, 08:11:37 PM by devnull »
|
Logged
|
-- Licensed User --
|
|
|
|
jarry
|
 |
« Reply #5 on: December 16, 2014, 08:23:30 PM » |
|
Override the $.fn.form.defaults.onChange to define the default behavior. $.extend($.fn.form.defaults, { onChange:function(t){ console.log('form onChange') } })
You can also override the 'onChange' on the specified form. <form class="easyui-form" data-options=" onChange: function(t){ console.log('overriden onChange') } "> <input class="easyui-textbox"> </form>
|
|
|
|
|
Logged
|
|
|
|
|
devnull
|
 |
« Reply #6 on: December 16, 2014, 08:33:39 PM » |
|
Thanks, yes that's what I have already.
I can get it to fire when I attach to a specific form, but it does not appear to fire when using the eui extend defaults.
|
|
|
|
|
Logged
|
-- Licensed User --
|
|
|
|
jarry
|
 |
« Reply #7 on: December 16, 2014, 08:43:16 PM » |
|
If you want to let the both 'onChange' events to be triggered, please try to override the form plugin. (function($){ var plugin = $.fn.form; $.fn.form = function(options, param){ if (typeof options == 'string'){ return plugin.call(this, options, param); } else { return this.each(function(){ plugin.call($(this), options, param); var opts = $(this).form('options'); var onChange = opts.onChange; if (onChange && onChange != $.fn.form.defaults.onChange){ opts.onChange = function(t){ $.fn.form.defaults.onChange.call(this, t); onChange.call(this, t); } } }); } }; $.fn.form.methods = plugin.methods; $.fn.form.defaults = plugin.defaults; $.fn.form.parseOptions = plugin.parseOptions; })(jQuery);
|
|
|
|
|
Logged
|
|
|
|
|
devnull
|
 |
« Reply #8 on: December 18, 2014, 02:09:58 AM » |
|
Sorry, I got distracted and have been working on other issues. $.extend($.fn.form.defaults, { onChange:function(t){ console.log('form onChange') } })
This does not fire at all in my system, does it fire in yours ??
|
|
|
|
|
Logged
|
-- Licensed User --
|
|
|
|
jarry
|
 |
« Reply #9 on: December 18, 2014, 04:06:12 AM » |
|
Please try the attached example 'test.html'.
|
|
|
|
|
Logged
|
|
|
|
|
devnull
|
 |
« Reply #10 on: January 03, 2015, 05:18:09 PM » |
|
Hi Jarry;
This is a REALLY useful feature thanks so much for adding it, will it be part of the standard code ??
|
|
|
|
|
Logged
|
-- Licensed User --
|
|
|
|