http://stilbuero.de Klaus Hartl – Stilbüro - Klaus Hartl


Jump to: Search, Additional Information.


Archive for the 'jQuery' Category

jQuery Delegate plugin – cross-browser submit/reset event delegation

Dan Webb has written an event delegation plugin the other day (as part of Low Pro for jQuery) – I really like his solution and as soon as you are working with Ajax page updates a lot you got to love the ease the event delegation technique provides.

There is one major drawback though. In IE submit and reset events do not bubble, thus you cannot use delegation here. Same is true for submit events in Safari 2.

In the upcoming Plazes delegation for submit/reset events turned out to be a requirement, so I wrote an event delegation plugin based on Dan Webb’s stuff, in particular on what Yehuda Katz proposed in one of the comments, and added workarounds for IE and Safari, so that you can now use delegation for these events just as you would expect. There were also some issues with using confirm().

I needed to do that quickly, thus the code could use some optimization (later).

Get it here:
http://stilbuero.de/jquery/delegate/

I just noticed that Jörn Zaefferer wrote something similar for the focus and blur events and I’m going to merge the two.

jQuery UI Tabs aka Tabs 3

Being a part of the jQuery UI project, UI Tabs aka Tabs 3 has been released the other day.

Until today I have fixed a bunch of bugs that popped up and I hope Tabs 3 is stable now. I’ve added a couple of frequently requested features but please be aware that the new Tabs require jQuery 1.2.1 and also that I have left away history support for now. The history plugin itself needs a major overhaul and when that is done I will build it into Tabs again. I have closed down comments on all of the Tabs 2 posts to indicate that this version will not be maintained any longer.

If you’d like to report a bug, I’d like to ask to you to file a ticket. This way it’s much easier to keep track of bugs and if you post a bug in the comments I will create a ticket anyway.

To be consistent with other UI modules, i.e. to conform to some conventions we set up, the Tabs API has changed quite a bit. The documentation, which has been moved from the source file to the jQuery documentation Wiki is your friend (and because it’s a Wiki everybody can help to improve it – remember I’m not a native english speaker and documenting code is not always easy for me). I’ll also write a follow-up post about the most important changes and additions.

A demo is here.

Thank you for using Tabs!

Tabs Plugin: More flexibility

Just a short note, I’ve updated the CSS for the Tabs plugin – because people did not stop asking – and tabs have a flexible width and height again. They still maintain a minimal width as well, so that tabs with short titles, as in the demo, will have the same width. Otherwise it would look a little cluttered (well, at least to me). I’m using a sprite technique for the different parts of the tab of course, thus only one image needs to be downloaded.

Important to know is that this required an additional span element nested in the anchor element of a tab.

Tabs 2.7: Flexibility

I’ve added a few requested features and fixed some quirks for the Tabs plugin recently.

Tabs plugin update: Support for (unobtrusive) Ajax

I have updated the Tabs plugin the other day. It now supports loading tab
content via Ajax. As one could have expected I did that in an unobtrusive manner.

The HTML you need is slightly different from the one that is used for static tabs: A list of links pointing to existing ressources (from where the content gets loaded) and no additional containers at all (unobtrusive!). They’re going to be created on the fly:

<div id="container">
     <ul>
         <li><a href="ahah_1.html">Content 1</a></li>
         <li><a href="ahah_2.html">Content 2</a></li>
         <li><a href="ahah_3.html">Content 3</a></li>
     </ul>
</div>

Initialize the tabs interface with the remote option set to true:

$('#container').tabs({remote: true});

Obviously this will degrade gracefully – the links, e.g. the content, will still be accessible with JavaScript disabled.

All other options and history support should be totally unaffected by that.

There’s another option: While the tab content is being loaded a little spinner left to the tab title text is shown (which you will hardly see on the demo, because it’s loading too fast). Just like in Firefox for example. This is controlled by a CSS class, which you can change:

$('#container').tabs({remote: true, loadingClass: 'progress'});

If you don’t want to show a spinner at all just remove the rule

.anchors .tabs-selected .tabs-loading {
     ...
}

from the style sheet.

New kids on the jQuery block

Sweet! I am an official member of the jQuery team since yesterday.

This is pretty exciting and I’m looking forward to bring in my capabilities to an already strong team!

A smoother Thickbox (with less code)

Here’s an instruction on how to make the beautiful Thickbox even better. These things came to my mind while I was implementing Thickbox for Plazes. The result is a much smoother Thickbox with much less JavaScript code.

Tabs Version 2

Since the first release of my jQuery Tabs plugin I constantly worked on it – which is most notable if you take a look at the demo page – but until now I have never officially released a new version. Since I made a little API change recently and because I think the plugin is pretty mature now, I hereby announce version 2 of the jQuery Tabs plugin. I’m going to describe all changes and additions since version 1.

Cookie Plugin for jQuery

I contributed a cookie plugin for jQuery yesterday. You can get it from the (Subversion) repository:

svn://jquery.com/plugins

Or get it here. A few simple examples of how to use it:

$.cookie('the_cookie'); // get cookie
$.cookie('the_cookie', 'the_value'); // set cookie
$.cookie('the_cookie', 'the_value', { expires: 7 }); // set cookie with an expiration date seven days in the future
$.cookie('the_cookie', '', { expires: -1 }); // delete cookie

You’ll find the complete documentation inline.

Update

Ralf Engelschall suggested on the jQuery mailing list, that it is more intuitive to delete a cookie by passing null as value:

$.cookie('the_cookie', null); // delete cookie

I agree and updated the plugin accordingly. The old syntax for deleting still works of course.

Bookmarkable Tabs

Some further enhancement for the tabs plugin: the ability to bookmark a tab. It’s already in the demo for quite a while but I had not yet posted it (apart from from the jQuery mailing list).

Navigate through posts



Klaus Hartl – Stilbüro is powered by WordPress, jQuery, XHTML, CSS and me.