$.event.special.trigger

$.event.special.trigger

hello!
I'm trying to create my own submit event.

How can I execute my ajax function after all callbacks was executed? I was trying to do this like that:
  1. function ajax(){
  2.     alert('ajax');
  3. }
  4. ajax.last = true;
  5. if(window.console) alert = console.log;
  6. $.event.special.submit = {
  7.     add: function ( evt, b ) {
  8.         var evts = $(this).data().events.submit,
  9.             i = evts.length;
  10.         while(i--) {
  11.             if( evts[i].last === true ) {
  12.                 evts.push(evts.splice(i,1))
  13.                 break;
  14.             }
  15.         }
  16.     }
  17. }
  18. $('p').submit(ajax);
  19. $('p').submit(function(){
  20.     alert('custom')
  21. }).submit();
But it doesn't work, because $.event.special.add executes before handker was added to stack.

P.S. Also, it woud be nice to have something like $.event.special.trigger(event) and $.event.special.afterTrigger(event, isStopped);