Permalink
Browse files

Attach handlers only once

init may be called multiple times, so make sure we attach event handlers
only once.
  • Loading branch information...
bluesmoon committed Jan 24, 2013
1 parent 2c1b5e7 commit 21d5a978a6e78f2e5df8951b3a96c32991f504e0
Showing with 5 additions and 0 deletions.
  1. +5 −0 boomerang.js
View
@@ -67,6 +67,7 @@ impl = {
onloadfired: false, onloadfired: false,
handlers_attached: false,
events: { events: {
"page_ready": [], "page_ready": [],
"page_unload": [], "page_unload": [],
@@ -277,6 +278,9 @@ boomr = {
} }
} }
if(impl.handlers_attached)
return this;
// The developer can override onload by setting autorun to false // The developer can override onload by setting autorun to false
if(!impl.onloadfired && (!("autorun" in config) || config.autorun !== false)) { if(!impl.onloadfired && (!("autorun" in config) || config.autorun !== false)) {
if(d.readyState && d.readyState === "complete") { if(d.readyState && d.readyState === "complete") {
@@ -316,6 +320,7 @@ boomr = {
impl.addListener(w, "unload", function() { BOOMR.window=w=null; }); impl.addListener(w, "unload", function() { BOOMR.window=w=null; });
} }
impl.handlers_attached = true;
return this; return this;
}, },

0 comments on commit 21d5a97

Please sign in to comment.