JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test Global event</title>
</head>
<body><div id="main">
<div id="test">Du texte</div>
<button id="trigger">CLICK</button>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
var test = $("#test"),
trigger = $("#trigger");
test.bind('custom.namespace', function(e) {
console.log('Custom - ' + e.namespace)
})
test.bind('custom.namespace2', function(e) {
console.log('Custom - ' + e.namespace)
})
trigger.click(function() {
//Doit déclencher custom quelque soit le namespace -> OK
console.log('Trigger de custom via click')
test.trigger('custom');
//Doit déclencher custom uniquement pour le namespace "namespace" -> Pas OK
console.log('Trigger de custom.namespace via click')
test.trigger('custom.namespace');
});
//Doit déclencher custom quelque soit le namespace -> OK
console.log('Trigger de custom')
jQuery.event.trigger('custom');
//Doit déclencher custom uniquement pour le namespace "namespace" -> Pas OK
console.log('Trigger de custom.namespace')
jQuery.event.trigger('custom.namespace');
})
</script>
<div></body>
</html>