need help with JQUERY UI dialog that keeps submitting

need help with JQUERY UI dialog that keeps submitting

Hi,

I'm trying to create a generic function that I can use on all my pages. I want a dialog message to appear if the user has changed anything but not saved it.

Now it sort of works as I get the dialog message but it still submits the page before I have had a chance to reply i.e to cancel or continue with the request.

This is what I have I'm using JQUERY UI 1.7.2
This is what I have in my header
$jquery('a').filter(function(){ return (
                      this.href.search("&APP_ID.:&APP_PAGE_ID.:") == -1 ||
                      this.href.search("CREATE") == -1 ||
                      this.href.search("CREATE_AND_CREATE_ANOTHER") == -1)})
        .click(function(){ alert(this.href);$jquery("#CONFIRM").dialog({modal: true,
                              buttons : {
                                'Continue': function() {
                                   //need to close the dialog and continue to the selected href
                                    $(this).dialog('close');
                                 },
                              Cancel: function() {
                                    //need to close the dialog and cancel the request and stay on the current page.
                                    $(this).dialog('close');
                                 }
                              }
                        });
         });


Is it possible to add to a the list of href that I want to filter out on demand?

This is the div with my dialog in
<div id="CONFIRM" style="display:none" title="WARNING - Unsaved data exists!">You have made changes to data on this page.  If you navigate away from this page without first saving your data, the changes will be lost.</div>



Why does it keep submitting