[jQuery] events, lock and unlock
Hi everybody,
I have the next silly problem:
$(myobject).bind('myevent', function() {
var anotherobject = new MyCustomObject();
$(anotherobject).bind('anotherevent', function() {
// code here
});
});
and then I write these two lines:
$(myobject).trigger('myevent');
$(myobject).trigger('myevent');
The problem is that sometimes 'myevent' is dispatched before the
'anotherevent' and I would like to be sure that the 'anotherevent' has
been dispached previously. I'm thinking in something like this:
$(myobject).bind('myevent', function() {
// here we lock 'myevent'
$(myobject).lockEvent('myevent);
var anotherobject = new MyCustomObject();
$(anotherobject).bind('anotherevent', function() {
// code here
// here we unlock 'myevent' so we are sure 'myevent' is dispached
after the 'anotherevent'
$(myobject).unlockEvent('myevent');
});
});
I now it is a strange question :) and I currently I'm doing it in
another way, but I'm curios about it.
Thank you in advance and sorry for my English.