0
$(top.document).ready(function () {   

   $(document).click(processAction);



function processAction(e){
    var clicked = e.target;
newDialog("You've Clicked On A Link !")

function newDialog(mytitle){
   var $dialog = $('<div id="myunique"></div>')
        .html("<a href='http://sss.com'>click</a>")
        .dialog({
            autoOpen: false,
            modal: true,
            title: mytitle
        });
    $dialog.dialog('open');
    return false
}

});

The problem I am having is that when I click anywhere in the dialog, a new dialog popups, and it seems to produce several of these in a row.

My goal is: catch all the clicks on page EXCEPT the elements inside the dialog.

1 Answer 1

1

your problem is probably here:

$(document).click(processAction);

this means that any time you click anywhere on your page, the processAction() method runs!

change this so that it only runs when a button or link is clicked and it should solve your problem.

EDIT: according to your edit you want to capture clicks outside your dialog box. Check out this thread for instructions on how to do this.

Sign up to request clarification or add additional context in comments.

5 Comments

i tried $('body').delegate('*:not(#mymenu *)','click', processAction); and it doesn't work
yes, because that means that whenever someone clicks anywhere on the page it will run your method. set your click handler to something like $('.mylink').click(processAction)
even doing this $('body').delegate('a:not(#mymenu *)','click', processAction); results in a new dialog spawning when I click the link inside the dialog....
the reason I am doing this is, I need to catch all the clicks EXCEPT the elements inside the dialog.
tried the event.stopPropagation method but as soon as I click on teh link, the dialog appears and then it navigates to the following page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.