binding multiple custom name-spaced events

binding multiple custom name-spaced events


I am trying to bind multiple custom name-spaced events with one
handler and it seems that only the final event gets added... This
feels like a bug to me, but maybe there is some logical reason for it?
$(window)
.bind( "test.one test.two", function(ev){
console.log(ev.type+'.'+ev.handler.type);
})
.trigger("test.one").trigger('test.two');
The same result happens if I try it this way...
var fn = function(ev){ console.log(ev.type+'.'+ev.handler.type); }
$(window)
.bind( "test.one",fn).bind("test.two",fn)
.trigger("test.one").trigger('test.two');
I only get the expected result when using unique handlers...
$(window)
.bind("test.one",function(ev){
console.log(ev.type+'.'+ev.handler.type);
})
.bind("test.two",function(ev){
console.log(ev.type+'.'+ev.handler.type);
})
.trigger("test.one").trigger('test.two');
Shouldn't I be able to bind multiple events with one handler?
Is the problem I am having because of the name-spacing?
Using different types of events and one handler works as I expect...
$(window)
.bind( "test1 test2", function(ev){ console.log(ev.type); })
.trigger("test1").trigger('test2');
Do I have the name-spacing backwards? If I am trying to publish/
subscribe custom events in a plugin, should the event be called
"plugin.disable" or "disable.plugin"? I thought the former... now I am
not so sure.