hey guys i was just going through the code of carousel.js and i am a little bit confused , now we it comes to attaching events i ofte see code as follows ::
$('a').click(fuction(e){
if(e.target.targetNode == $(this)[0])
//do something
});
I am still a bit confused , who is passing the e ? WHO really is passing that e inside the function ?
also in the plugin code i see things like the below :
Carousel.prototype.keydown = function (e) {
if (/input|textarea/i.test(e.target.tagName)) return
switch (e.which) {
case 37: this.prev(); break
case 39: this.next(); break
default: return
}
an event handler is attached like so :
this.options.keyboard && this.$element.on('keydown.bs.carousel', $.proxy(this.keydown, this))
another example is here :
Carousel.prototype.pause = function (e) {
e || (this.paused = true)
if (this.$element.find('.next, .prev').length && $.support.transition) {
this.$element.trigger($.support.transition.end)
}
this.interval = clearInterval(this.interval)
return this
}
Who is passing e inside these functions , from where is it coming from ? i have absolutly no clue , i have been using JS for a while now , but this still baffles me . can somebody really clear this doubt for me once and for all ?
P.S. I have seen this answer on SO , but it does't answer the questions i have asked . I understand that e is in a way a object with differentv properties that we can access.
Aucun commentaire:
Enregistrer un commentaire