ModalWindow and jQuery mousedown binding

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

ModalWindow and jQuery mousedown binding

neilbennett
Hi,

I am experiencing an issue very similar to Andrew Geery here, http://apache-wicket.1842946.n4.nabble.com/weird-interaction-between-ModalWindow-and-jQuery-mousedown-binding-td4473055.html

I have a ModalWindow open with a datetimepicker (http://www.malot.fr/bootstrap-datetimepicker/) component. On non-ModalWindow pages this component closes if open when clicked outside of it's area, but the ModalWindow consumes the mousedown event and so datetimepicker is not closed when clicking outside of it or even when the modal window is closed itself.

Are there any ideas on how to have these ModalWindow mousedown events not be consumed?

Thanks,

Neil
Reply | Threaded
Open this post in threaded view
|

Re: ModalWindow and jQuery mousedown binding

Martin Grigorov-4
Hi,

I don't know what is the reason to stop the event at
https://github.com/apache/wicket/blob/master/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/modal.js?source=c#L1186

You can remove that binding with:
jQuery('.wicket-modal .w_content_1')[0].onmousedown = null; // or =
function() {};


 Martin Grigorov
Wicket Training and Consulting


On Fri, Mar 7, 2014 at 6:22 PM, neilbennett <[hidden email]>wrote:

> Hi,
>
> I am experiencing an issue very similar to Andrew Geery here,
>
> http://apache-wicket.1842946.n4.nabble.com/weird-interaction-between-ModalWindow-and-jQuery-mousedown-binding-td4473055.html
>
> I have a ModalWindow open with a datetimepicker
> (http://www.malot.fr/bootstrap-datetimepicker/) component. On
> non-ModalWindow pages this component closes if open when clicked outside of
> it's area, but the ModalWindow consumes the mousedown event and so
> datetimepicker is not closed when clicking outside of it or even when the
> modal window is closed itself.
>
> Are there any ideas on how to have these ModalWindow mousedown events not
> be
> consumed?
>
> Thanks,
>
> Neil
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/ModalWindow-and-jQuery-mousedown-binding-tp4664859.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: ModalWindow and jQuery mousedown binding

neilbennett
Thanks for the reply. I actually removed that binding from the html output but I don't see any noticeable changes in behavior. Clicks on the modalwindow still do not trigger the mousedown binding on the datetime component unless it is outside of the modal window.

I have limited javascript knowledge, hence why using Wicket, but I'm stumped on where to look on why these events aren't being sent to the datetime component.

Thanks,

Neil
Reply | Threaded
Open this post in threaded view
|

Re: ModalWindow and jQuery mousedown binding

Martin Grigorov-4
Hi,

You can use Google Chrome's Event Listener Breakpoints and see where
mousedown is trapped.
Dev Tools -> Sources -> right pane -> Event Listener Breakpoints -> Mouse
->mousedown

Martin Grigorov
Wicket Training and Consulting


On Tue, Mar 11, 2014 at 11:32 PM, neilbennett <[hidden email]>wrote:

> Thanks for the reply. I actually removed that binding from the html output
> but I don't see any noticeable changes in behavior. Clicks on the
> modalwindow still do not trigger the mousedown binding on the datetime
> component unless it is outside of the modal window.
>
> I have limited javascript knowledge, hence why using Wicket, but I'm
> stumped
> on where to look on why these events aren't being sent to the datetime
> component.
>
> Thanks,
>
> Neil
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/ModalWindow-and-jQuery-mousedown-binding-tp4664859p4664902.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: ModalWindow and jQuery mousedown binding

neilbennett
Hello again. Thanks for your help, I've found what occurs. When removing onmousedown="Wicket.Event.stop(event);" from the w_content_1 div, the event then propagates. However, the mouseDownHandler function is called in the Drag class in wicket-ajax-jquery.js this returns false which then stops further event propagation. Commenting out the return false then allows my component popup window to close.

So that's the cause, I'm not sure of the best way to work around this. I can crudely remove the bindings/return value, but I'm sure that will break things. Thought I'd report back anyway - if anyone has any suggestions to work around this or what would break/not break from changing this.

Thanks,

Neil
Reply | Threaded
Open this post in threaded view
|

Re: ModalWindow and jQuery mousedown binding

Martin Grigorov-4
Hi,

Thanks for sharing your findings !

On Wed, Apr 2, 2014 at 11:20 PM, neilbennett <[hidden email]>wrote:

> Hello again. Thanks for your help, I've found what occurs. When removing
> onmousedown="Wicket.Event.stop(event);" from the w_content_1 div, the event
> then propagates. However, the mouseDownHandler function is called in the
> Drag class in wicket-ajax-jquery.js this returns false which then stops
> further event propagation. Commenting out the return false then allows my
> component popup window to close.
>

I am not sure why only commenting out the return statement helps.
At
https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js#L2410there
is another Wicket.Event.stop(event) call that I think also should
mess the things up in your case ...


>
> So that's the cause, I'm not sure of the best way to work around this. I
> can
> crudely remove the bindings/return value, but I'm sure that will break
> things. Thought I'd report back anyway - if anyone has any suggestions to
> work around this or what would break/not break from changing this.
>

I am also not aware why this code needs to stop the propagation of the
event.
Please file a bug in our Jira with a quickstart and I'll try to find out.


>
> Thanks,
>
> Neil
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/ModalWindow-and-jQuery-mousedown-binding-tp4664859p4665236.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: ModalWindow and jQuery mousedown binding

neilbennett
Hi Martin,

You are exactly right. The other Wicket.Event.stop(event) does need to be commented out. I've found that while this does allow pop-up's to be closed, it also stops fields taking focus. I will submit a JIRA issue with a quickstart though.

Thanks,

Neil