openam / bootstrap-responsive-tabs

Bootstrap responsive tabs are tabs that switch to collapsible components (accordions) when resized.
openam.github.io/bootstrap-responsive-tabs
MIT License
132 stars 60 forks source link

Error thrown when relatedTarget doesn't exist #3

Closed annatopol closed 10 years ago

annatopol commented 10 years ago

In collapsed mode when all tabs start out collapsed first click on a collapsed "tab" seemingly has no effect and causes an error to be thrown "Cannot read property 'hash' of undefined" on line 126 of responsive-tabs.js

Replacing

    var $current  = $($(e.target)[0].hash.replace(/#/, '#collapse-')),
    $previous = $($(e.relatedTarget)[0].hash.replace(/#/, '#collapse-'));

    $current.collapse('show');
    $previous.collapse('hide');

with the following:

    var $current  = $($(e.target)[0].hash.replace(/#/, '#collapse-'));
    $current.collapse('show');

    if(e.relatedTarget){
        var $previous = $($(e.relatedTarget)[0].hash.replace(/#/, '#collapse-'));
        $previous.collapse('hide');
    }

remedies the issue.