Reputation: 138
My code looks like:
'click #foo': function(e, t) {
$('#otherId').click();
//further instructions
}
At this moment, 'further instructions' are made, and then 'otherId' is clicked. I need to click 'otherId' first of all, before #foo will make other instructions. I know that click() is working asynchronous but I am not able to work this out. Is there any (simple) way to add priority to $('otherId').click(); instruction?
Upvotes: 0
Views: 60
Reputation: 74738
You can make use of callbacks:
function furtherInst(){
// further instructions
}
now in your event bindings:
'click #foo': function(e, t) {
$('#otherId').click();
},
'click #otherId': function() {
// other instructions
furtherInst(); // call it here at the end
}
Upvotes: 0
Reputation: 328
I would write it like this
'click #foo': function(e, t) {
$('#otherId').click(function(){
//further instructions
});
$('#otherId').trigger('click');
}
Upvotes: 0
Reputation: 22158
I don't know what framework do you are using, but you can try this:
'click #foo': function(e, t) {
$('#otherId').click();
},
'click #otherId': function() {
// further instructions
}
When you trigger the click, then listen it and make the other instructions
Upvotes: 1