mardi 24 février 2015

Using jQuery with Ember action handler

I am trying to access jquery object ($) from inside a action handler in ember controller. But it says $ is undefined.


How do you get access to jQuery object from an action handler?


Take this app for example:



<div id="main"></div>

<script type="text/x-handlebars" data-template-name="index">
<div id="scroll-div">
<h1>Test Div</h1>

</div>
<a href="" {{action "findHeight"}}>Find height</a>
</script>


JS



App = Ember.Application.create({
rootElement: '#main'
});

App.IndexController = Ember.ArrayController.extend({
actions: {
findHeight: function(){
console.log(this.$('#scroll-div').height);
}
}
});


JS fiddle: http://ift.tt/1JG0bKi





Aucun commentaire:

Enregistrer un commentaire