EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: gordis gmbh on September 14, 2015, 10:14:21 AM



Title: timespinner save value onblur
Post by: gordis gmbh on September 14, 2015, 10:14:21 AM
I have a timespinner and want to trigger save-function once the user spins/types to set the time and leaves the spinner(onblur). But the problem is, the onblur event gets triggered even during the spinner is spinned! I think this is a bug.
Please find a demo here:http://jsfiddle.net/gk4bgo66/ (http://jsfiddle.net/gk4bgo66/)

Calling the save-function for every spin is not good. Any idea how this can be handled?

Thanks for your help.


Title: Re: timespinner save value onblur
Post by: chrwei on September 14, 2015, 01:15:20 PM
since you're putting on the blur on the textbox itself, clicking the arrows triggers a blur.  one thing I can think of is to have the blur check e.relatedTarget to see if it's one of the arrows, and if it is, don't submit.


Title: Re: timespinner save value onblur
Post by: gordis gmbh on September 15, 2015, 09:10:16 AM
Thanks for the clue - it did help me get further.

However, i'm not sure if relying on spin-arrows will be good because there are multiple closely located spinners on the page and hence I thought, I will use "document.activeElement" to check if the focus is still on the spinners:: http://jsfiddle.net/2hy9jz2h/ (http://jsfiddle.net/2hy9jz2h/)

The problem with this approach is that the save doesn't get called if the focus is out of the document!

Any further hints will be of great help. Thanks.



Title: Re: timespinner save value onblur
Post by: chrwei on September 15, 2015, 11:48:00 AM
there's probably a cleaner way, but this works http://jsfiddle.net/cqfra40y/