shown.bs.dropdown Related target
shown.bs.dropdown Related target
Created by: DaGLiMiOuX
Hi there!
Im using Bootstrap v3.3.5 and I'm having some troubles using the dropdown menu and accessing to the dropdown events. According to documentation (http://getbootstrap.com/javascript/#dropdowns-events) all dropdown events (show, shown, hide and hidden) has a relatedTarget property to access the anchor that fired the event. It works perfect in show and hide events, but shows undefined in shown and hidden events.
Is there an error in the documentation or did you miss to put that property when the event was built?
Here is an example of my code:
$('.dropup').on('show.bs.dropdown', function(e){
console.log(e.relatedTarget);
});
$('.dropup').on('shown.bs.dropdown', function(e){
console.log(e.relatedTarget);
});
$('.dropup').on('hide.bs.dropdown', function(e){
console.log(e.relatedTarget);
});
$('.dropup').on('hidden.bs.dropdown', function(e){
console.log(e.relatedTarget);
});
Thanks in advance.
Regards, Diego.
PS: I'm using Windows 7 with Chrome 43.0.2357.132 m
EDIT: I've been checking all events objects through console.log(e) and they all have the same properties with exactly same values, only "timestamp" property is the one that is not the same in all event objects, and I found that hidden and shown events has not defined the relatedTarget property, but in the bootstrap.js file there is this piece code:
$parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
if (e.isDefaultPrevented()) return
$this.attr('aria-expanded', 'false')
$parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
relatedTarget is theorically sent, correct me if I'm wrong, in both hide events and the same where show events are thrown.