Reputation: 32808
I want to execute the following:
$('#AccountID').change(SelectAccounts);
and then (SelectProducts)
Is there some way I can make the function SelectProducts execute after SelectAccounts all on the same line?
Upvotes: 1
Views: 2096
Reputation: 54022
use jQuery.Callbacks()
added from jQuery v1.7
var callbacks = $.Callbacks();
callbacks.add( SelectAccounts);
callbacks.add( SelectProducts );
//then use callbacks.fire() with supported flags
Upvotes: 0
Reputation: 10887
Those are two different functions so you'd need to call them separately.
$('#AccountID').change(function () {
SelectAccounts();
SelectProducts();
});
In case you need to control the exact execution time for the second function, this discussion might be useful: Upon Link Click and setTimeout
Upvotes: 1
Reputation: 126052
How about:
$("#AccountID").change(SelectAccounts).change(SelectProducts);
(in jQuery, event handlers are executed in the order they're bound. SelectAccounts
will always run before SelectProducts
)
Upvotes: 5