Reputation: 662
In a meteor.js app, I am trying to return the position of a click using jQuery's .position().
If I use event
or this
, I'm getting the error Uncaught TypeError: Cannot read property 'defaultView' of undefined
.
If I use $( event.currentTarget )
, it returns 0
, since that defines the element that was clicked.
Template.myTemplate.events({
// Doesn't work
'click .target': function (event) {
posY = $(event).position().top; // Undefined error
console.log( posY )
},
// also doesn't work
'click .target': function (event) {
var $this = $( event.currentTarget );
posY = $this.position().top;
console.log( posY ) // Returns 0
}
});
In straight jQuery, I would do this:
$( '.target' ).click( function (e) {
var posY = $(this).position().top;
console.log( posY )
});
My question is, how do I access the same this
in Meteor?
Upvotes: 1
Views: 520