Reputation: 41433
I'm using a jQuery plugin called "backstretch". Within the description it says that backstretch.show
is called every time an image is changed. How would I go about listening for this event and getting it to perform another function when its called?
Upvotes: 1
Views: 645
Reputation: 2558
An event needs two things to know what to listen for, the event type (in this case, "backstretch.show"
, and the target. It looks like you apply .backstretch()
to a jQuery set, so you probably want to register your handler on elements of that set for the target, which are what get the event.
So I'd recommend something like:
$("something").backstretch(/* ... */).on("backstretch.show", function () {
//do something
});
Upvotes: 1
Reputation: 126042
Assuming:
$(".foo").backstretch("...");
Then:
$(".foo").on("backstretch.show", function () {
/* My code here */
});
If you're using the static version:
$.backstretch("...")
You may have to bind the event handler to the body:
$(document.body).on("backstretch.show", function () { ... });
Upvotes: 3