I’m trying to create a sticky header in an ember application. I just want to add a class to the <div id="stickyHeader"></div>
via jquery when the user starts scrolling on the page. I squeezed the jquery into an action, but nothing happens...
I’m more a designer than a developer so pretty sure I oversee something fundametal here.
I have a <div></div>
like this in my applications.hbs:
<div id="stickyHeader">
... some content ...
</div>
and an action in application.js:
...
actions: {
stickyHeaderClass: function(){
this(window).scroll('addClassOnScroll')
var scroll = this(window).scrollTop();
if (scroll >= 5) {
return Ember.$('#stickyHeader').addClass('active');
} else {
return Ember.$('#stickyHeader').removeClass('active');
}
},
....
I crapped the jquery stuff here. The rest is copy and paste ...
Any idea?
Aucun commentaire:
Enregistrer un commentaire