Representative jQuery; or Appendicitis
-
$myBoss: "Hey, you know that thing you did in the $websitePart, that 'clearbox' thing?"
$me: "Yeah, what about the lightbox?"
$myBoss: "You could add that to the comment system? We got complaints it's not too clear where one should type."
$me: "Uh, sure. It'll be done by monday."Mini-WTF: I added a transparent background to a dialog screen and since a designer called it a lightbox (which is the name of a bunch of jQuery plugins) the name stuck.
Ok, whatever, I decided to look how the HTML of the comment system was done. When I saw it was dynamically generated, I expected something terrible, but not... This.
Comments.html = $('<div>').attr('id', 'lightbox').append( $('<div>').addClass('Comments').append( $('<h1>') .append('COMMENTS - ') .append(Comments.dynamicHtml.title) .append(Comments.dynamicHtml.closeButton) ) .append(Comments.dynamicHtml.listComments) .append( Comments.dynamicHtml.form.append(Comments.dynamicHtml.inputMessage) ) ); // Which was presented to me like this: Comments.html = $('<div>').attr('id', 'lightbox').append($('<div>').addClass('Comments').append($('<h1>').append('COMMENTS - ').append(Comments.dynamicHtml.title).append(Comments.dynamicHtml.closeButton)).append(Comments.dynamicHtml.listComments).append(Comments.dynamicHtml.form.append(Comments.dynamicHtml.inputMessage)));
My best wishes go to whoever is employing this guy right now.
-
That's basically this in jQuery.
-
Most stuff involving jQuery has no real business involving jQuery these days.
-
I'd agree completely with you, but jQuery is easy to refactor and doesn't allows nearly as many awesome 1337 tricks that I prefer to fix a jQuery mess than pure JS.
-
I've become a big D3 js fan, though that's mostly because I deal with data visualization a lot.