jQuery custom plugin used with .on() -
I am using a custom plugin (below) which prevents a user stop / typing $ ( Elm), the plugin works fine when used. Doniting (function () {// do something}};
, however, I am thinking that it should be sent to some dynamically loaded content such as .on)
such as
$ (elm) ) .on ("donetping", "elm2", function)}); The plugin is: (function ($) {$ .fn.extend ({dotting: function (callback, timeout) {timeout = timeout 1e3 ; // 1 second default timeout verm time reference, typing = function (L) {if (timeout reference); timeout reference = empty; callback cal (L);}; return; function (i, el) {Var $ el = $ (el); // Chrome Fix (use keyboard on keyboard to detect backspace) // Thanks @ ParlorT $ el.is (': input') & amp; amp; $ el .on ('keyp Press', function (E) {// it captures the backspace button in Chrome, but it also prevents the event. Without this line, the element with focus will be lit by using the // tab / changes tab. Call (if e.type == 'funnel' & amp; amp; E.keycode! = 8);; check that the timeout has been set or not. If it is, the clock "reset" and // Resume. If (timeout reference) timeout reference (timeout reference); TimeoutReference = setTimeout (function () {// if I make it here, then our time is over. // Callbacked typing (L);}, timeout); }). ('Blurred', function () {// If we can, we can fire this incident because we are ending the field typing (L);}); }); }}); }) (JQuery);
I have taken a look around Google but I do not think I am searching for the right words.
P> .on
to control events To set a custom event called Dontiping
, you will need to change your plug-in and then register the callback to that handler.
Change your doneTyping method to: (Add trigger)
doneTyping = function (el) {if (TimeoutReference) return; Timeout reference = null; If (callback) {callback.call (el); } $ (L) .Progress ('donating'); };
And then try it:
$ (document) .on ('donetyping', '.dynamic-element', function () {console log ('Typed', $ (this));});
Comments
Post a Comment