jQuery Session at RailsConf

Posted on by

RailsConf 2007

I’m happy to announce that my proposal for a Birds of a Feather session about “jQuery on Rails” at RailsConf has been accepted!

If you’re at RailsConf, please come by room c125 on Thursday night at 9:30pm and join in the discussion. I’ll be chatting about my ongoing work on jQuery on Rails, and should have some code to demo if anyone would be interested.

If you’re interested in hearing about how others have solved problems regarding the integration of jQuery with Rails, or just want to share something cool you’ve done, swing on by. See you there!

More Details

Yehuda has just posted more details on how jQuery on Rails works:

Since I last publicly discussed jQuery on Rails, I’ve gone down a lot of avenues, and written a lot of code, and came to some conclusions:

  • jQuery and Unobtrusive JavaScript are fundamentally incompatible with an attempt to describe behavior inside markup, as Rails does via “JavaScript helpers.”
  • Attempts to fix the problem, specifically UJS for Rails, still require that you include your JS behaviors in your views, which are then marshalled into JavaScript files on the fly (and cached as appropriate). If you wanted to include the same JS behavior in multiple pages, you’d need to create custom helpers and call out to them.
  • jQuery is already the perfect mechanism for unobtrusive JavaScript, baked right into the library
  • The biggest problem faced by jQuery developers is not simplicity (which, again, you get for free in the library), but difficulty in including the correct jQuery “modules” in the Rails views that require them.

The most common problem with using jQuery with Rails in an app of moderate or higher complexity is the trade-off between including everything in a single application.js (which can lead to serious slowdowns in larger apps) and having multiple, modular files (which are a serious pain to include correctly as needed).

This is a problem for jQuery users who want to use Rails more than Rails users who are used to Prototype helpers and want to be able to use the jQuery library as a drop-in replacement. In the first release of jQuery on Rails, I will be targeting jQuery developers who want to work with Rails. In other words, jQuery on Rails is for you if you know jQuery or are willing to use jQuery.

This release of jQuery is not for you if you don’t want to learn jQuery, and want to program purely in Ruby. There will be a future release that will include some features for pure-Ruby developers, but I maintain that Unobtrusive JavaScript is fundamentally incompatible with that mode of thinking.

With all that said, what does jQuery on Rails actually do?

First up, it’s a Rails plugin, which you activate by adding <%= include_jquery %> in your application.rhtml. When your server is started, it’ll parse all of your JavaScript files, and identify selectors in those files. When include_jquery is called in your layout, it’ll get the rendered HTML and use Hpricot (which shares syntax with jQuery) to determine whether any instances of the selectors identified on server startup are present.

The JavaScript files that have selectors that are also present in your HTML will be loaded, and run as expected.

So in short:

  • Create your JavaScript files, using selectors as usual
  • Use include_jquery in your layout
  • You’re done

Fisheye Dock Menu

Posted on by

Fisheye Dock Menu

With a little bit of nice theming, the Fisheye component from Interface has been adapted to build a beautiful “CSS dock menu“. It’s currently making all the rounds on design blogs and on Digg.

Some more information about what this menu was designed for can be found on the developer’s site:

If you are a big Mac fan, you will love this CSS dock menu that I designed. It is using jQuery JavaScript library and Fisheye component from Interface and some of my icons. It comes with two dock styles – top and bottom. This CSS dock menu is perfect to add on to my WordPress iTheme. Here I will show you how to implement it to your web page.

Learning jQuery Book Details

Posted on by

This week Jonathan Chaffer and I finished the book’s first draft and sent the last chapter to the publisher, so I thought I’d take this opportunity before the revisions start rolling in to provide some more details. The book’s full title is Learning jQuery: Better Interaction Design and Web Development with Simple JavaScript Techniques. Learning jQuery bookAs the subtitle suggests, we’ve written the book to be accessible to those with a web-design background who haven’t had much, if any experience, with coding. But we think it will provide plenty of useful information for intermediate-level scripters as well.

The book is being published by PACKT Publishing, based in Manchester Birmingham, UK. They’re a relative newcomer to the publishing world, but already they’ve managed to put together a pretty impressive group of books, many of which explore open-source software projects. They seem passionate about supporting these projects beyond publishing books about them. In fact, they’ve introduced a royalty scheme that gives a percentage of sales to the open-source project that a book is written about. So, if you buy this book, you’ll be directly supporting the jQuery project. :)

The expected publication date is sometime this July, and the book is already available for pre-order at a 20% discount. The publisher plans to sell a PDF-version of the book, too, but they haven’t set it up for pre-order just yet.

Barring the unlikely major structural change during our revision phase, the (concise) table of contents should look like something like this:

  1. Introducing jQuery
    1. Getting Started
  2. Exploring jQuery
    1. Selectors, or How to Get Anything You Want
    2. Events, or How to Pull the Trigger
    3. Effects, or How to Add Flair to Your Actions
    4. DOM Manipulation, or How to Change Your Page on Command
    5. AJAX, or How to Make Your Site Buzzword Compliant
  3. Using jQuery
    1. Table Manipulation
    2. Forms with Function
    3. Shufflers and Rotators
  4. Examining jQuery
    1. Selector Expressions
    2. DOM Traversal Methods
    3. DOM Manipulation Methods
    4. Event Methods
    5. Effect Methods
    6. AJAX Methods
    7. Miscellaneous Methods
    8. Plug-ins
  5. Appendices
    1. Online Resources
    2. Development Tools
    3. JavaScript Closures

Update:

We’re making good progress on the revisions, and it looks like we’re going to hit our target publication date of July. The publisher has just made the PDF version of the book available for pre-order at a 15% discount. Also, they have a “Book and eBook Bundle” at an enormously discounted price (US $36.79).

Google Groups and Amazon S3

Posted on by

Two new improvements have just gone into place to help improve the quality of the jQuery site.

The jQuery Mailing List is now hosted with Google Groups.

This move is going to help provide huge increases in the overall speed, and quality, of the jQuery mailing list. At the time of the move we were sending out, approximately, 4.5m emails per month. Unfortunately, the list was prone to folding under the high server load; and the amount of effort required to keep it performing nicely was simply too much to ignore.

The best feature of the new mailing list (besides the increased reliability) is the addition of Google Groups’ wonderful web-based interface. I hope that everyone who’s asked for a forum can now be content knowing that they can browse the jQuery list, and easily reply to posts, without ever having to subscribe to incoming messages.

Note: If you were a member of the old mailing list, you should be completely moved to the new one. All old messages and users were moved over, and everything should be intact.

Complete instructions on how to use the main discussion mailing list, and all the other jQuery mailing lists, can be found on here: jQuery Mailing Lists.

All code is now hosted with Amazon S3.

As a project, we’ve never discouraged first time users from using the jQuery Source Code straight from their personal site; it helps to get new users started with development, without having to worry about keeping their code up to date.

Needless to say, the number of users who’ve directly used the jQuery source directly from the jQuery site has increased dramatically in recent months (with some large-scale sites directly pulling from jQuery.com). This still isn’t a huge problem, but it’s something that the web server hosting jQuery.com shouldn’t have to worry about. For that reason, all jQuery source code has been moved to Amazon S3, for example: http://code.jquery.com/jquery-latest.js.

The jQuery site has been using the code directly from Amazon S3 for over two weeks now and I’ve been very pleased with the results. The number of files requested has dropped dramatically, giving the web server more time to serve the normal jQuery web pages.

Note: All old requests to http://jquery.com/src/… are being redirected to the http://code.jquery.com/… sub-domain (which is managed by Amazon).

A nice thing about this move is that we can soon start providing dedicated hosting for plugins. Once we figure out the logistics of the plugin repository (which is currently under development), we’ll be sure to make that a priority.

Additionally, static jQuery.com files (like stylesheets, images, and JavaScript files) are being hosted directly from Amazon S3 too (static.jquery.com). This is also helping to alleviate any strain on the server that may be present.

As always, if you get any errors on the jQuery site, please be sure to send a message to the mailing list, where we can find it and help to solve the problem.

1.1.3 News

All of these site issues have delayed jQuery 1.1.3 slightly, but now that they’re out of the way we should be back on track for having a 1.1.3 alpha out by the end of this week. This update is going to include significant updates to the performance of jQuery animations and huge speed increases to the selector engine; as well as fixing over 20 outstanding bugs. We hope to have an update concerning all of this, shortly.

jQuery Book Coming Soon

Posted on by

For those of you who have been following the jQuery blog the past couple months, you may have noticed John Resig’s mention of a secret: “There’s a jQuery book in the works!” Well, I am thrilled to be able to leak a little more information about that secret.

For the past few months my friend Jonathan Chaffer and I have been hard at work on the book, and everything is progressing well. Our writing is being supported by a stellar group of technical reviewers, some of whom are members of the jQuery development team. We’ll be able to divulge details about the book’s contents soon. The publisher is readying a web page for it, so as soon as that is completed, we can give you the full scoop.

About the Authors

Jonathan Chaffer is a long-time Drupal contributor and creator of Drupal’s CCK. He also likes to make up bizarre band names and album titles, based on snippets of conversations he overhears, at Tweak the Viking. Karl Swedberg (that’s me) is a jQuery zealot who runs the Learning jQuery blog and still tries to keep a bit of his former career as an English teacher alive at his other blog, English Rules. Jonathan and Karl work together at Structure Interactive in Grand Rapids, Michigan, where they have been given a lot of freedom to use jQuery, as well as standards-based, semantic HTML & CSS, in many of their projects.

SXSWi jQuery Meetup

Posted on by

Right now the annual SXSWi conference is happening in beautiful, sunny, Austin, Texas. Interestingly enough, there’s a ton of jQuery users here (as am I). I’ve already had the opportunity to talk with a number of you, but we should really do a proper get together.

As proposed by Luke Lutman, on the mailing list, and Cody Lindley (of Thickbox fame) – let’s do a meetup! Let’s say Monday (Mar 12th) at lunch. Meet at the main doors facing the Courtyard Hotel. If you have any troubles, feel free to give me a call at 585-615-5287 and I’ll direct you in.

I’m looking forward to meeting everyone!

See Also: http://upcoming.org/event/162778/

Update: Just to clarify, this is at 12:30pm (after the 11:30am-12:30pm session ends). And the doors are at the corner of Trinity and and Fourth St. I’ll be wearing a bright red Atari T-Shirt, so I should be easy to spot.

jQuery 1.1.2

Posted on by

Translations: Italiano, français

The release of jQuery 1.1.2 is upon us! This is a another bug fix release. We’ve fixed a number of outstanding issues. The fixes have been tested well, so there shouldn’t be any regressions (knock on wood). The most noticeable issue that was resolved was related to animation flickers when doing a slideDown.

It is highly recommended that you upgrade.

As always, if you have any questions or concerns with new release, please feel free to discuss it on the jQuery Mailing List. If you think you’ve spotted a bug, please add it to the bug tracker.

Download

Bug Fixes

The most important bug fixes, relevant to this release, are as follows:

  1. Change: Event handlers (like element.onclick) are now removed when no more functions are bound to the event.
  2. Fixed: DOM Manipulations for form elements.
  3. Fixed: jQuery.isFunction to return false on nodes.
  4. Fixed: jQuery.className.has, escaping regex characters in className (for metadata)
  5. Fixed: an issue in IE where an event on a cloned element is fired during a .clone() inside of an event handler.
  6. Fixed: IE ID selectors selecting by the name attribute.
  7. Changed: Events are now internally stored in elem.$events rather than elem.events (due to a nasty bug relating to DOM 0 expandos).
  8. Changed: .attr('href') is now consistent in all browsers.
  9. Changed: @href is now consistent in all browsers.
  10. Fixed: the slideDown flickering bug.
  11. Fixed: Having a \r endline in $("...") caused a never-ending loop.
  12. Fixed: IE6 AJAX memory leak
  13. Fixed: bug in pushStack, reporting an element at [0] in a jQuery object with length 0

Documentation

Additionally, the documentation has been back-ported out of the wiki and into the API docs. All of the documentation resources have been updated in respect to the 1.1.2 release.

Leading up to jQuery 1.1.3…

This may seem like a fairly light bug fix release, but we’re gearing up to the release of jQuery 1.1.3. A number of outstanding bugs (about 5-10) require significant changes to how jQuery works, internally (specifically, in relation to events and animations). We want to make 100% certain that there are no regressions made to these important pieces of code.

We have patches nearly ready (animation is ready, events is in the works) – and when that’s the case, we’re going to release a preview of the 1.1.3 code so that everyone can test against it.

Update: This has also been announced on Learning jQuery: jQuery 1.1.2 Released

Update: A nasty glitch in Safari was found and fixed. We just re-tagged jQuery (it’s now SVN rev 1465 instead of 1460 – this includes a fix for the bug, and it temporarily disables the test suite in Safari) and all the jQuery 1.1.2 downloads should be updated, as well.

jQuery is OpenAjax Compliant

Posted on by

OpenAjax Alliance

A new initiative has been forming, over the recent months, in an attempt to standardize the different Ajax and JavaScript codebases that exist. A number of corporate entities have come together to draft the new OpenAjax standard (including IBM, Adobe, Opera, and Mozilla).

Today we’re announcing a new plugin that you can use to make jQuery OpenAjax compliant. By doing this, jQuery is becoming one of the first projects that has made its codebase compliant with the new standard.

Currently, the requirements for compliance are, relatively, simple – but still quite important. The relevant rules can be summarized as such:

  • All libraries must register themselves (their name, version, and namespace) with the main OpenAjax library.
  • All libraries must register any global variables that they use (in the case of jQuery it’s ‘jQuery’, and optionally ‘$’ – it defaults to just including ‘jQuery’).
  • Any attempt to register “onload” or “onunload” handlers must go through the OpenAjax library. In the case of jQuery, if you do: $(window).load(function), and OpenAjax is included, jQuery will defer to OpenAjax’s solution.
  • Libraries must not disrupt the ability of other libraries to traverse the HTML DOM document.

You can view jQuery’s compliance results, to verify that it does, indeed, past the test suite.

If you wish to use jQuery in conjunction with other OpenAjax-capable libraries, the process is rather straight forward.

Step 1 Download a copy of the jQuery OpenAjax plugin to your server.

Step 2 Include the library in your site, just after you include jQuery.

<script src="jquery.js"></script>
<script src="jquery.openajax.js"></script>

Be sure to include both jQuery and the jQuery OpenAjax plugin after you’ve included the official OpenAjax library itself.

And that’s it! jQuery will now happily play with the OpenAjax core library.

It should be noted that, currently, jQuery is not part of the OpenAjax Alliance, but we’re in the process of applying and are eager to begin actively participating.

jQuery and Jack Slocum’s Ext

Posted on by

Ext JavaScript Library

Today, we’re proud to announce that the jQuery Project and Jack Slocum’s Ext Project, have partnered to integrate the amazingly lightweight and powerful jQuery framework with Ext’s awesome UI library. This collaboration will greatly enhance the capabilities of both projects and expand the functionality available to developers using the jQuery JavaScript Library and the Ext UI component suite.

Specifically, the upcoming Ext 1.0 release will be able to run, natively, on the jQuery JavaScript Library. No other libraries will be required. The jQuery and Ext teams are actively working together to bring this integration to the Ext codebase.

Here’s some possible questions and answers (feel free to post any others that you have in the comments):

What prompted the collaboration?

Ext has some fantastic components – arguably, the best on the web. jQuery has all the core functionality to support what Ext has. The jQuery team contacted Jack Slocum with the hopes that we could work together to add jQuery support to the Ext library, and Jack whole-heartedly agreed. It’s a win-win situation: jQuery gets some awesome components, Ext gets a huge influx of new users.

What are the benefits for jQuery and Ext users?

jQuery users gain a huge number of expertly-designed components that they will be able to deploy immediately. Additionally, they’ll be able to use them in a manner that better suits the jQuery philosophy (e.g. being able to call Ext queries on sets of elements, chaining calls, leveraging jQuery’s support for true unobtrusive DOM scripting etc.)

At the same time, existing Ext users will gain the flexibility of being able to continue to use Ext’s professional-caliber components while leveraging the lightweight, small (~19k) and powerful jQuery framework.

How will the two teams work together?

After the first beta release of Ext 1.0, jQuery will be providing a
strike team which will work to iron out all the integration points in Ext. At the same time, Jack will be working to isolate all the remaining framework-specific code, making it easier for us to finish the conversion process. All of this will be in place for Ext’s final 1.0 release, which will support both Yahoo UI and jQuery.

How will support be handled?

The jQuery team will be providing support for any bugs that may only exist in the jQuery version of Ext.

Support for Ext, itself, will continue to be handled via the Ext forums. The Ext project will also begin offering a level of paid support for its corporate users.

What Ext features will be included in Ext 1.0 for jQuery

All available Ext 1.0 features are going to be supported by jQuery.

The final feature list, for Ext 1.0, is still being finalized but a full breadth of new functionality can be expected.

When will Ext 1.0 for jQuery be available?

The final release date still has yet to be finalized and we will make a formal announcement on the jQuery blog, the jQuery mailing list, the Ext project site, and the Ext forums once the its ready to go.

An alpha release of Ext 1.0 was just released, but does not, yet, include the jQuery compatibility layer.

Do any licensing issues exist?

No. jQuery’s licensing will remain the same, and Ext 1.0 will be completely open source (LGPL).

Additionally, corporations will be able to purchase an Ext support license. This will include email support and SVN access, amongst other features.

Update: Digg this story up!

Examples

Here are examples of what you can do with Ext. (All demos currently run on Yahoo UI, as the Ext 1.0 alpha release doesn’t support jQuery.)

Paged, Dynamic, Grids

Ext Paged Grid

Mixed Content Menus

Ext Mixed Content Menus

Advanced Dialog Layout and Themes

Ext Dialog Layout

Message Box Dialog

Ext Message Box Dialog

Drag-and-Drop Trees

Ext Drag and Drop Trees

The jQuery IRC Channel

Posted on by

In addition to jQuery’s great Mailing List and Documentation, there’s another place where users can seek help about jQuery problems: We have a very active jQuery IRC channel.

Even though it’s never really been publicly announced, the channel currently averages over 50 simultaneous users, including some friendly jQuery bots! Hosted on irc.freenode.net, #jquery always has users who are online and willing to answer your questions (of which, they are often answered within minutes of their being asked).

Here’s the information that you will need in order to connect to the channel:
Server: irc.freenode.net
Room: #jquery

jQuery team members, especially John Resig (nick: JohnResig), Joern Zaefferer (nick: JoernZaefferer), and Yehuda Katz (nick: wycats) are frequently in attendance, helping experienced and new users alike with both complex and trivial problems.

The IRC Channel is best if you need quick help with any of the following:

  • JavaScript
  • jQuery Syntax
  • Problem Solving
  • Strange bugs


If your problem is more in-depth, we may ask you to post to the mailing list, or the bug tracker, so that we can help you in a more-suitable environment.

Additionally, we recently started logging the channel, so you can now look back through to find answers to your old problems: jQuery IRC channel Log