Christian Heilmann

You are currently browsing the archives for the Experiments category.

Archive for the ‘Experiments’ Category

\”More content\” links, cloneNode(), YUI and Safari/MSIE issues

Monday, August 14th, 2006

cloned sheep When I was creating a proof of concept the other day about how to create ‘more content’ links with JavaScript and the YUI I stumbled across an interesting problem with the YUI Event utility.

The Event Utility is IMHO the cat’s pajamas as it solves a lot of issues the tried and true addEvent didn’t: It retains the scope allowing you to use “this” in the listener method, makes preventDefault work in Safari and also allows you to send another custom object to the listener method, all of which make is a lot easier to write unobtrusive JavaScript without the memory leaks.

Now, the interesting problem I stumbled upon is that if you do the following

  • create a new link
  • add attributes, content and all that jazz
  • apply an event handler
  • clone the link
  • apply another handler to the second link

you’re in for trouble. Safari applies both handlers to the first link and none to the second, and MSIE applies both the first and the second handler (in reverse order) to the second link! Here’s the test case using YUI. The MSIE problem of the double handler on the second link also happens when you use the tradional addEvent.

I talked to the YUI folks and Adam told me that applying unique IDs to the links solves the issue in Safari, however it doesn’t make a difference in MSIE.

The lesson to take away:

If you clone elements, make sure to clone them before you apply the handlers, and remove all handlers just to be on the safe side

A shame, as I really like the idea of cloning elements. The other option of course is a constructor method for repeated elements.

Safari for Windows – well almost

Tuesday, August 8th, 2006

You can now get a WebKit based browser for PC, which allegedly works and renders like Safari.

It is called Swift and can be downloaded at http://www.getwebkit.org/

In order to keep the original PC/Windows vibe going, the install will crash unless you apply a patch beforehand.

Testing ahoy!

Chris

Win free ebooks and copies of my books!

Monday, August 7th, 2006

I just published a competition on The web site of Beginning JavaScript with DOM Scripting and Ajax with prices like free ebook vouchers, copies of said book or Web Accessibility: Web Standards and Regulatory Compliance . All you need to show is either a little creativity or lack of fear of public embarassment.

On to the competition

JavaScript/AJAX contractor needed in London ASAP

Wednesday, August 2nd, 2006

We are currently looking for a contractor to start ASAP at a approximately one week project implementing a user module on a large scale portal site.

The job will include Ajax and some PHP and you will have use the YUI library.

The successful applicant will have to join us in Covent Garden, London and may have to go for lunchbreaks and drinks!

Please supply demo URLs of projects you’ve done and what you expect in terms of rates as comments here – they are moderated which means only I will get them.

Is my quest for a good multi-platform IDE over?

Monday, July 31st, 2006

I just installed Aptana and peeked at some of the Aptana Screencasts to see what this IDE can do and I am very impressed.

I am a sold to Homesite, ever since version 2.5, but lately I found myself more and more using my Mac and I hate using different IDEs. WordWrangler and CSSEdit seemed to odd as an IDE (give me shortcuts, not floating toolbars), Dreamweaver was just too overwhelming and costs too much, and others were just not my cup of tea.

Aptana, however, seems to be really focused on web development and integrates all the big JavaScript libraries. That way using the YUI is a lot quicker as the IDE autocompletes all those long namespaces.

Now, if only I knew that it supports UTF-8 as well as UltraEdit does, then I’d be sold to this one. I’ll give it a spin and keep you updated as to my findings.