You can see my js (and associated html and css) at: http://jsfiddle.net/twsx7/9/
I am working on a tweak to work with Blackboard Learn 9.1 (so if anyone has experiencing with the learning management system, or with the tweaks building block they might have some clue already as to why I am getting this problem).
The change I am making involves checking what course theme is applied and then adding a class to a table based on that so that the table is styled to match the theme.
When i run this on our server I get the error $(...) is null when it reaches var theme_id = $(".current").attr("id");. The rest of the JS works (note that the top section of the JS is normally another file that's included on the page, couldn't link it to jsfiddle as its on an authenticated server)
My contributions to this file are (and where the code is failing):
line 242
$unitMap.addClass(getTheme());
lines 381 - 385
function getTheme() {
var theme_id = $(".current").attr("id"); // error occurs this line
var theme = $("#"+theme_id).find("a").html();
return theme.toUpperCase();
}
This is my first attempt at jQuery so one of my concerns is that I'm using the wrong syntax for the version of jQuery the code was written with.
I located the following within the code when you select to include a tweak:
<script src='/webapps/qut-tweakbb-BBLEARN/jquery.js' type='text/javascript'></script><script src='/webapps/qut-tweakbb-BBLEARN/jquery.tweakSetup.js' type='text/javascript'></script>
The code in the top of the jsFiddle is from jquery.tweakSetup.js
I am hoping I've just used the wrong markup for the version of jQuery (though I can't seam to find what version the original code was written in) any advice would be greatly appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…