View Full Version : [FIXED] Bug in relayEvents together with prefix

12 Oct 2011, 8:13 AM
I just noted that the relayEvents function in util.Observable fails if I provide a prefix for the relayed event. Normally I would assume that the prefix is simply added to the old event name, for instance like this:

relayed event = "load"
prefix = "layers"
--> new event = "layersload"

In fact the function substrings the old event name by the length of the prefix which makes absolutely no sense, or?

relayEvents : function(origin, events, prefix) {
prefix = prefix || '';
var me = this,
len = events.length,
i = 0,

for (; i < len; i++) {
oldName = events[i].substr(prefix.length);
newName = prefix + oldName;
me.events[newName] = me.events[newName] || true;
origin.on(oldName, me.createRelayer(newName));

13 Oct 2011, 12:57 AM
Yeah, something's gone wrong there. Thanks for the report.