I have very easy JavaScript/CoffeSscript knowledge.
I’m wondering if there’s a better way to bind the placing the active class only when tableContentsPane is opened.
$(document).ready ->
$('#tableContents').click ->
$('#tableContentsPane').toggle();
$("#tableContents").addClass "active" if $("#tableContentsPane").is(":visible")
$("#tableContents").removeClass "active" if $("#tableContentsPane").is(":hidden")
$('#tableContentsPane a').click ->
$('#tableContentsPane').toggle();
$("#tableContents").removeClass "active" if $("#tableContentsPane").is(":hidden")
Instead of using an
ifto see if the table is open or not you can simply toggle the classI believe this will meet all your conditions
API reference http://api.jquery.com/toggleClass/