Take the 2-minute tour ×

So since the jQuery confirm box looks awesome I figured we need to make it actually usefull by making it possible to use it together with all other click events and inline handlers without hassles and ugly hacks like redirecting the browser url.

So I came up with this EDIT new version jQuery confirm dialog idea to capture click events before onclick can get triggered

I figure when accessing the eventHandler of that object, it is already to late to update the inline handlers. Or is there a way?

The code:

    $(".needsFancyConfirm").each(function(index, ele){
        ele.attr("onclick", "return false;"); //preventDefault would do the same imho

         bgiframe: true,
         height: 300,
         modal: true,
         buttons: {
              SubmitFormWithAllOldOnclickEvents: function() {
                  ele.unbind("click", "click.foo");
                 console.info(ele.attr('onclick') + " <-- just to make sure what is written in Onclick, now we will execute it");
                  console.info($("#coolIdea")[0].onclick() + " <-- this returns false - it should return the set old onclick e.g. alert Wow u managed to execute me");

share|improve this question

1 Answer 1

up vote 0 down vote accepted

So i think this is basically a chicken and egg problem.

At the moment we capture the event there is no way to change the eventhandlers since they were already read.

share|improve this answer

Your Answer


