jQuery tooltips using ajax

So you’ve got some tooltip text you want to show your user, but it’s a bit expensive to generate that text and you only really want to go to the bother of generating it when the user invokes the tooltip.

In my situation this was a bunch of numbers on a page, each of which had been calculated by a particularly long and complicated piece of business logic, and the users need to let the page ‘show its working’ now and again.  On a busy page, the agreed UI solution was to put the detail into a tooltip, but I didn’t want to have to pre-populate every cell with a tooltip, when the users probably wouldn’t bother looking at it at all, and when they did they’d only be interested in one or two cells.  So…

HTML: (on my page this bit is repeated many times)

<span
  class="tooltip"
  title="Default tooltip for when the ajax call fails"
  data-id="${line.someId}">${complicatedNumber}</span>

jQuery:

$("span.tooltip").tooltip({
	content: function( event, ui ) {
		var element = $( this );
		var id = element.attr("data-id");
		var tooltiptext = "Default tooltip";

		// Non-async ajax is deprecated, but we're using it
		// here because  we need to get the tooltip text
		// synchronously so that the response is processed
		// in time.
		$.ajax({
			async:false,
			dataType: 'text',
			url:'/tooltip/rest/' + id,
			type:'get',
			success: function(response) {
				tooltiptext = response;
			}
		});
		return tooltiptext;	   
	}
});

Windy Widemouth

The remnants of Hurricane Bertha hit whilst we were away. We spent the morning acting as ballast in the tent to stop it blowing away, but ventured down to the beach at Widemouth Bay once the wind died down a bit. In splendidly British fashion, we splashed about a bit as people in full wet-weather gear walked past, bemused and amused.

It was quite lumpy.

IMG_0570

Boscastle

That place no-one had heard of until it got massively flooded in August 2004.  We went there last year and kept driving as it was wet and windy.  This time it was just windy so we parked at the (unflooded, rebuilt) car park, and walked up the coastal path for a bit.  We didn’t expect to get to the folly at the top of the headland, but once you get a little bit closer it’s hard to resist…

IMG_0786

Hill on the hill

Another photo from Goodwood.  Damon Hill in his 1996 championship winning Williams FW18.

 

Make your own rainbows

This was the rather nicely timed Typhoon display during the Goodwood Festival of Speed.  He appeared just as one of the Nobles cleared out the hay bales at Molecombe and everything stopped for a while.IMG_9399

H2O

IMG_7806

Locked

20140211-222022.jpg

Everyone else was taking pictures of the nicely swollen Stour, there, but I’d never noticed that people had started leaving padlocks on this bridge, a bit like the ones in the rest of Europe.

Taken with my iPhone, and then messed with a bit using the ColorTime app.

Dashfiller

IMG_2479

A friend of mine is (slowly) renovating an old VW camper van.  It’s quite rare, apparently, to find an original radio that still works, so it’s fairly common to buy a non-working example from one of the various internet sources and use it to fill the gap in the dashboard where the radio should go.  Hence, a “dashfiller”.

This one is slightly the wrong vintage for the intended ‘van, so it’s going to be up for sale soon.