radiac.net

diary - latest entries

Rubbish Bin Ettiquette

31st December 2008 at 10:546 comments

It has come to my attention that it has literally been months since I last wrote about anything that is of no consequence. I shall therefore correct this oversight immediately.

Since I last wrote about rubbish, there have been startling developments here at Radiac Towers regarding our bins - we now have a rota. We stopped doing the bins about a year ago, mostly because someone has taken to putting them out the morning before, 24 hours in advance. The council can fine you if you put it out before 6pm, so we're not in a hurry to compete for liability. However, the neighbour in question apparently tired of doing it on their own, so told the building management to arrange a rota. Our first week was Christmas week, but we were both away, so we swapped with a neighbour to this week.

Because of Christmas and New Year national holidays, our bin collection has been postponed until Friday. We were aware of this because we are competent. Sadly, the lovely neighbour who we swapped with was not aware of the change, thought that collection day was today as usual, and that we had forgotten to take the rubbish out, so dragged the bins to the kerb this morning.

Now, this mix-up is hardly going to keep me awake at night, but what is the correct course of action in this situation? Should I care what the neighbour thinks, and go round to explain in order to clear my name? Should I drag the rubbish back inside, and leave a passive-aggressive note pinned to the top of the bins? Or should I empty the rubbish on the neighbour's doorstep, and jump up and down in it excitedly screaming 'RUBBISH' at the top of my voice, over and over again, until she calls the police and has me taken away? Or should I just stop wasting my time with this entry, and get on with my work?

Life is full of dilemmas.

In other news, yesterday I saw an Easter egg for sale in the Co-op - 4 months and 14 days early. Needless to say, I bought it and ate it. Happy Easter!

Building with jQuery, IE and invalid markup

29th December 2008 at 16:29Comment

Ran into an interesting problem when using jQuery to generate DOM from markup: make sure your markup is valid, otherwise jQuery's html function will fail silently in Internet Explorer.

A quick and simple illustration with some invalid markup:

$('#content').html('<div>content</div></div>');

Firefox ignores the second div, but IE does not, and causes it to fail. You will instead find that the innerHTML of your #content element is empty.

This won't happen every time, and depends on exactly how your markup is broken; for example, <div><div>content</div> is also wrong, but will not cause this problem.

As any js developer will testify, these are the most fun kind of problems, especially when the line in question is part of a far larger library, buried in a series of asynchronous anonymous functions, and surrounded by various things that are far more likely to be the cause, such as non-json cross-domain POSTs and GETs, for example. Needless to say, the problem first appeared to be completely unrelated, and I wasted a fair bit of time on this one.

The issue actually seems to be in jQuery.clear(), so it affects html(), jQuery(html), append(), prepend(), after(), before() etc - in fact, any jQuery function that is supposed to parse raw html and add it to the DOM. Functions that set or replace content will set it to nothing; ones that append or prepend content will leave existing content unaffected.

There are several obvious ways to test for this failure, but the easiest seems to be to check whether the html() is null:

var $newContent = $('<div>content</div></div>');
if ($newContent.html() == null) {
    // The content was invalid in IE, raise an error
    return;
}
$('#content').empty().append($newContent);

Simple solution, simple problem, bloody annoying.

Ho Ho Ho

1st December 2008 at 00:003 comments

Slade is playing, the decorations are up for the 10th year in a row, and TCMI is online... it can mean only one thing: it's that magical time of year at radiac.net again!

Tee hee

30th November 2008 at 23:591 comment
You know what to expect...

I Really Need To Fancy This Up

29th October 2008 at 08:3510 comments

Top of my to-do list for this site is adding a link feed so I can avoid short entries like this one.

BoingBoing linked to an amusing video of the presidential debates...