jQuery UI Widgets Forums Dialogs and Notifications Window Hide popup if click detected elsewhere

This topic contains 2 replies, has 2 voices, and was last updated by  Nadezhda 9 years, 11 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • Hide popup if click detected elsewhere #64978

    arkgroup
    Participant

    Is it possible to close window when click out site of it?
    I open window on icon click and try to close on body click, but it does not work (icon is in the body)
    Any suggestions?

    Thanks

    Hide popup if click detected elsewhere #65023

    arkgroup
    Participant

    Looks like this code is working…

    $(document).mouseup(function (e) {
    var container = $(“#popupWindow”);

    if (!container.is(e.target) // if the target of the click isn’t the container…
    && container.has(e.target).length === 0) // … nor a descendant of the container
    {
    $(“#popupWindow”).jqxWindow(‘close’);

    }
    });

    Hide popup if click detected elsewhere #65025

    Nadezhda
    Participant

    Hello arkgroup,

    You can also use event.stopPropagation(); or event.cancelBubble = true; to stop the click event from bubbling to parent elements. Here are the examples:

    1) event.stopPropagation

    $(document).on("click", function (event) {//second way
        event.stopPropagation();
         $('#jqxwindow').jqxWindow('close');
    });

    2) event.cancelBubble

    $(document).on("click", function () {
        event.cancelBubble = true;
        $('#jqxwindow').jqxWindow('close');                
    });

    Best Regards,
    Nadezhda

    jQWidgets team
    http://www.jqwidgets.com/

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.