$.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:
- function ajax(){
- alert('ajax');
- }
- ajax.last = true;
- if(window.console) alert = console.log;
- $.event.special.submit = {
- add: function ( evt, b ) {
- var evts = $(this).data().events.submit,
- i = evts.length;
- while(i--) {
- if( evts[i].last === true ) {
- evts.push(evts.splice(i,1))
- break;
- }
- }
- }
- }
- $('p').submit(ajax);
- $('p').submit(function(){
- alert('custom')
- }).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);