framework7

Open full view…

Dom Library .scroll method not working on second page

muoch10
Tue, 12 Aug 2014 07:51:16 GMT

So I have my index.html. It has a link to about.html. That all works. In my javascript file I have this: $$("*").scroll(function () { console.log("Scroll"); }); I would expect "Scroll" to be console.log'ed every time I start to scroll on the page. This works on the index.html, but when I click the link that goes to about.html, it stops working. It doesn't seem that the .scroll method works on any page but the first page. I also tried using jquery instead of framework7's DOM library, neither work.

Vladimir Kharlampidi
Tue, 12 Aug 2014 10:36:23 GMT

That is because when you add event listener, the next page is not yet in DOM and will not work. That is super bad idea to use "*" selector for adding events. You can use it like: --- $$(document).on('scroll', '.page-content', function(){ console.log('scroll'); })