Fancybox left and right key problem

When you use fancybox, it automatically adds listeners which stop any other use of the Esc, Left and Right keys on your keyboard. The just don’t work in forms etc inside Fancybox.

This isn’t such an issue with the escape key, but not being able to use the left and right, for example in text inputs, is a pain.

The changes below add an additional option to Fancybox called useNextPrev which you can set to false to stop Fancybox adding listeners to these keys. I haven’t included the escape key as I think it’s far less of an issue. Continue reading

MySQL Toggle a Fields Value

UPDATE `table_name` 
SET `field_name` = (SELECT CASE `field_name` WHEN 1 THEN 0 ELSE 1 END) 
WHERE `id_column` = 1

Or with text strings

UPDATE `table_name` 
SET `field_name` = (SELECT CASE `field_name` WHEN 'foo' THEN 'bar' ELSE 'foo' END) 
WHERE `id_column` = 1

More powerful jQuery getScript with cache control

If you love getScript as a shortcut method in jQuery, but you hate not being able to control whether the script calls from the browsers cache or not then you can override the built-in function with a new one which is backwards compatible, so it won’t break any of your old code, and allows you to choose true or false to caching.

Read the original post by Jamie Thompson (via Internet Archive)

(function($){
$.getScript = function(url, callback, cache){
	$.ajax({
			type: "GET",
			url: url,
			success: callback,
			dataType: "script",
			cache: cache
	});
};
})(jQuery)

[carousel keywords=”jquery” tag=”fetchit-21″]

Making Facebook Share Button Fit In

The share buttons that are currently offered by sites such as Digg, Facebook and Tweetmeme all have something in common when it comes to their height. 61px seems to be a developing standard.

The problem is that when you line them all up the Facebook share button is actually wider than the others which seem to come in at 52px.

Well you can make the Facebook button 52px in width without too much trouble. Facebook only use two classes to style the inner ‘Share’ button which seems to be the decider when it comes to the buttons width.

By shaving a little off the left and right padding we can bring the Facebook share button back down to 52px in width and make it play nice with the other share buttons.


The extra span is just enough to beat the included Facebook css with a higher specificity score by 1 single point.

[carousel keywords=”facebook development” tag=”fetchit-21″]

WorldPay Response URL and Shopper Return for Thanks

Update May 2011 – This may be against terms and conditions. See Martin Brown’s comment below

It took a while to get my head around it, so here it is incase I need it again.

Integrating with WorldPay is not the simplest of tasks. The documentation is poor at best.

I was integrating by using a form on my site, which posts the order total and an order id etc to WorldPay. WorldPay then deal with taking the money from the user. What I couldn’t understand was how to get the user back to my site for thanks after they had paid.

Turns out it’s quite simple.

Continue reading