I (heart) jQuery

I (heart) jQuery

Wednesday, September 26th, 2007

I added jQuery into the mix today. It should be able to replace all of the functions currently used in engine.js

As an example, expanding and collapsing items. Up until the revision 89, around 45 lines were used for working out what was clicked and changing it and the background. It took every click and checked whether it was needed. If it was, it went through complicated processes working out what to do.
With jQuery, it’s all handled for us, and the only code we need is:
$(document).ready(function() {
$(".title").click(function(){
$(this).next().next().slideToggle().parent().toggleClass("c1").toggleClass("c2");
});
});

Review: We cut down 45 lines to 3 lines! Everything is handled for us now by jQuery and is about 4 times faster. Plus, it’s ultra easy to add new features, like the removal of date headers. Thanks jQuery!