Archive for the ‘Quick tip’ Category

Click event handler iPhone: non-anchor elements

Friday, March 15th, 2013

I have a results table where each row is a form and the user continues by pressing the submit button for that result. At smaller widths I collapse the table, hide the submit button and add a click event handler to the tr – it works fine, up to a point.

A filter bar was added that uses AJAX to reorder and add to the results so now the DOM is being generated with JS. Usually you can use .on(event, selector, handler) to catch any generated elements, but this won’t work on iPhone or iPad*. (more…)

Same page references, or named anchors

Wednesday, August 22nd, 2012

Named anchors have been around since HTML was created and allowed you to link to a different part of a page. They can be referenced by external page by using a hash then the identifier after the URL (more…)

Chrome won’t center button using auto margins

Thursday, March 3rd, 2011

Note: I’m not American, but it feels weird writing ‘centre’ if you code in CSS all day.

I’ve come across a problem I need solving and Google is not being my friend. I need to center a button on the page without specifying its width, because the text inside is of various lengths. The following works how I want in Firefox, Safari, Opera and even IE6, 7 and 9 (thanks to Sarah for testing). (more…)

jQuery Cookie problem – persistence and duplication

Wednesday, January 5th, 2011

I’ve started to use cookies to maintain user state and the jQuery Cookie plugin provides simple functions to create, read and delete cookies. However, I came across a problem where state didn’t appear to be persisting and on viewing the cookie information, using the web developer toolbar, I had multiple versions of the same cookie. (more…)

Front-end developer essentials – 5 tips for efficient jQuery

Saturday, December 11th, 2010

Over the last few months I’d like to think my skills in jQuery have got a lot better, I’ve been using it everyday and for more than just showing and hiding areas of a page. Along the way I’ve read about a few ways in which you can make your code a bit more efficient. (more…)