Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Custom jQuery events triggered on non-DOM elements that bubble (propagate) up to the 'document'
<script type="text/javascript" src=""></script>
<script type="text/javascript">
//non-DOM object events that propagate up to the 'document'
$(document).bind('customEventName', function(e, payload){
// non-DOM object
var obj = {};
obj.ownerDocument = document; //magic happens here
$(obj).trigger("customEventName", {content: "Witchcraft"})

This comment has been minimized.

Copy link

alexandis commented Nov 12, 2015

Tried this. Does not work. I have to use $(document) for trigger instead...

Anyway, bubble does not happen. Have to use some other approach...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.