Closed banks closed 11 years ago
Makes sense. Realistically, I'd caution against putting event handlers or data on the elements themselves -- in an infinite list, that's going to eat a lot of memory. That said, destroying the handlers and data is pretty unexpected/bad behavior; I'll slot it for the next sub-version release. Feel free to submit the pull request!
Indeed -- jquery 1.7 style event handlers, bound to a containing element but restricted by a selector are the way to go.
Merged in @saiwong's changes, which should fix this.
Thanks @saiwong, @reissbaker.
Currently when a
Page
is stashed to save memory the visible DOM is removed withthis.$el.remove()
inPage.stash()
. This causes all jQuery data and event handlers to be removed from theListItems
removed.When you scroll back up and those elements are restored, they no longer respond to events or contain data bound prior to the stashing.
I can trivially fix this by replacing
replace()
calls withdetach()
calls in each ofstash()
,appendTo()
andprependTo()
methods ofPage
.I think this should be all that is required.
Page.remove()
andListItem.remove()
should keep jQueryremove()
semantics and that should be sufficient to ensure that old stuff is cleaned up correctly when actually removed whilst maintaining bound data and events through stashing.Is that reasoning about where to keep and where to remove data and events sound? I can submit a pull request for this if so.