{"action":"created","issue":{"url":"https://api.github.com/repos/readium/readium-shared-js/issues/164","labels_url":"https://api.github.com/repos/readium/readium-shared-js/issues/164/labels{/name}","comments_url":"https://api.github.com/repos/readium/readium-shared-js/issues/164/comments","events_url":"https://api.github.com/repos/readium/readium-shared-js/issues/164/events","html_url":"https://github.com/readium/readium-shared-js/issues/164","id":60492982,"number":164,"title":"Clean up event listeners from reader_view.js","user":{"login":"einarstubhaug","id":5663392,"avatar_url":"https://avatars.githubusercontent.com/u/5663392?v=3","gravatar_id":"","url":"https://api.github.com/users/einarstubhaug","html_url":"https://github.com/einarstubhaug","followers_url":"https://api.github.com/users/einarstubhaug/followers","following_url":"https://api.github.com/users/einarstubhaug/following{/other_user}","gists_url":"https://api.github.com/users/einarstubhaug/gists{/gist_id}","starred_url":"https://api.github.com/users/einarstubhaug/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/einarstubhaug/subscriptions","organizations_url":"https://api.github.com/users/einarstubhaug/orgs","repos_url":"https://api.github.com/users/einarstubhaug/repos","events_url":"https://api.github.com/users/einarstubhaug/events{/privacy}","received_events_url":"https://api.github.com/users/einarstubhaug/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-10T12:38:19Z","updated_at":"2015-03-16T08:13:09Z","closed_at":null,"body":"I've come across an issue with a single-page javascript application.\r\n\r\nWe instantiate a ReaderView. When the user leaves this view, we remove the Readium iFrame from DOM alltogether (later, if the user wants to go back, we populate it from scratch). \r\n\r\nThe issue: If we have left the view and removed the iframe, and we resize the browser window , we get an error message from Readium. We managed to trace it to this line of code where an event listener is attached to the Window:\r\nhttps://github.com/readium/readium-shared-js/blob/master/js/views/reader_view.js#L67\r\n\r\n```\r\n$(window).on(\"resize.ReadiumSDK.readerView\", lazyResize);\r\n```\r\n\r\nIf we, when leaving the view, remove the event listener like this: \r\n```\r\n$(window).off(\"resize.ReadiumSDK.readerView\");\r\n```\r\nour code works. But I guess there might be more events being listened to which might cause problems later on.\r\n\r\nAre there any ways to reset and remove a ReaderView's event listeners in the Readium API?\r\n\r\nTips much appreciated, \r\n\r\nEinar"},"comment":{"url":"https://api.github.com/repos/readium/readium-shared-js/issues/comments/81482829","html_url":"https://github.com/readium/readium-shared-js/issues/164#issuecomment-81482829","issue_url":"https://api.github.com/repos/readium/readium-shared-js/issues/164","id":81482829,"user":{"login":"jansc","id":204638,"avatar_url":"https://avatars.githubusercontent.com/u/204638?v=3","gravatar_id":"","url":"https://api.github.com/users/jansc","html_url":"https://github.com/jansc","followers_url":"https://api.github.com/users/jansc/followers","following_url":"https://api.github.com/users/jansc/following{/other_user}","gists_url":"https://api.github.com/users/jansc/gists{/gist_id}","starred_url":"https://api.github.com/users/jansc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jansc/subscriptions","organizations_url":"https://api.github.com/users/jansc/orgs","repos_url":"https://api.github.com/users/jansc/repos","events_url":"https://api.github.com/users/jansc/events{/privacy}","received_events_url":"https://api.github.com/users/jansc/received_events","type":"User","site_admin":false},"created_at":"2015-03-16T08:13:09Z","updated_at":"2015-03-16T08:13:09Z","body":"I suggest that readium-shared-js and readium-js should provide its own unload function, e.g.\r\n\r\n```\r\nReadiumSDK.reader.unload()\r\n```\r\nand possibly\r\n```\r\nReadium.unload();\r\n```\r\n\r\nThat way, readium-js-viewer does not have to know about the internals in readium-shared-js. We could contribute pull-requests if you agree, @danielweck.\r\n"}}