showoff
showoff copied to clipboard
Custom events are fired twice
Hi!
Given the slides below, the string "event" is logged twice. The event should only be fired once, right?
This happens for at least "show" and "next". Tested on OS X Safari.
!SLIDE
First slide
!SLIDE a_very_unique_class
# Second
@@@ java
public class MyClass {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
<script>
$(".a_very_unique_class").bind("showoff:show", function (event) {
console.log("event");
});
</script>
!SLIDE
# Third
I'm not entirely certain what is happening here, but the root of the problem is that the $(".a_very_unique_class") selector is returning an array of two identical objects. I'll keep working on it, but for now, a decent mitigation is to stop event propagation in your event handler:
$(".a_very_unique_class").bind("showoff:show", function (event) {
console.log("event");
event.stopPropagation();
});
Hi @binford2k !
Thanks for looking at this, and for the workaround.