jquery

03 Sep

jQuery Checkboxes: Checking and unchecking the right way

in html, javascript, jquery

When working with checkboxes in jQuery and JavaScript, sometimes all you really want to do is toggle the checked state of the checkbox. There are many examples of strange ways of accomplishing this, many of which are wrong or will only work on some browsers. Here is a correct (XHTML-correct) and compact way of doing this.

Check to see if a checkbox is checked

// Returns a boolean, true if checked, false otherwise
jQuery('#my-checkbox').is(':checked');

Check a checkbox

08 Aug

A PHP jQuery Library: QueryPath Overview

in javascript, jquery, php, programming, querypath

jQuery is a JavaScript library for efficiently working with HTML and CSS. Its chainable and compact API has made it a popular choice for web developers seeking to quickly build rich web applications. But did you know there is a PHP jQuery library? QueryPath is a PHP implementation of jQuery's interface. It provides all of the DOM manipulation functions, a full CSS selector engine, and as much of jQuery's other features as is practically implemented server-side. But that's not all. This powerful library delivers many server-side features designed to make working with XML services simple, robust, and reliable.

30 Nov

Dave Hall: Review of "Drupal 6, JavaScript, and jQuery"

in books, drupal, javascript, jquery

Dave Hall recently reviewed my Drupal 6, JavaScript, and jQuery book.

Dave Hall's BlogDave Hall's Blog

I found this observation particularly apt:

This book is definitely not for the copy and paste coder, nor the developer who just wants ready made solutions they can quickly hack into an existing project. Some may disagree, but I think this is a real positive of this book. Matt uses the examples to illustrate certain concepts or features which he wants the reader to understand. I found the examples got me thinking about what I wanted to use JS and jQuery for in my Drupal sites.

This is what I want to accomplish in the book. My goal is to get coders thinking about what they can do (and how they can do it) rather than simply re-using code. I'm so glad that Dave noticed this and brought it into focus. If you are interested in taking a peek at the book, you can download one of the chapters.

02 Jul

Review of "Drupal 6 JavaScript and jQuery"

in drupal, javascript, jquery

Kat Bailey posted a very kind review of my Drupal 6 JavaScript and jQuery book.

From the review:

The book aims to get people with little to no knowledge of Drupal or JavaScript up to speed with creating really awesome functionality, really fast. In fact, its title almost belies the breadth of its scope: although the use of jQuery in Drupal 6 is the one topic that it covers exhaustively, it doesn't skip over any of the basic tools or concepts required to get going with Drupal, and so it would work pretty well as a first Drupal book for any aspiring front-end Drupaler. It covers everything from the ultra-utra-basic ("what is CSS?", "what is a Drupal block?") to Drupal JavaScript Behaviors (and everything else in drupal.js), to JavaScript Theming, to AJAX, to building modules with AJAX functionality, to jQuery syntax, effects, and even writing jQuery plugins!

I've spent the last week or so doing nothing but writing Drupal-centered JavaScript. Every time I reflect back on what JavaScript coding used to be like, I can't help but appreciate the hard work of the jQuery and Drupal JavaScript teams.

08 Jun

Presentations from Drupal Camp Wisconsin

in drupal, drupalcampwi, education, javascript, jquery, querypath

DrupalCampWIDrupalCampWILast weekend, I joined a couple hundred other Drupal users at Drupal Camp Wisconsin at the University of Wisconsin, Madison. This well-organized two-day event was fantastic. I met many new people (and can now connect a face with an IRC handle for many more). And the crack team of conference organizers have already put together videos of many conference sessions.

For me, the conference highlights included a handful of sessions on Drupal in education, a pair of sessions on GIS and mapping, and a BOF that I attended on web services, portlets, and the future of distributed web applications. A perennial strong point for Drupal Camps is the coverage of Drupal basics. DrupalCampWI had around half a dozen sessions for beginners. If you are just learning Drupal, a camp like this can really help you find your footing.

The camp's commons area was fantastic, providing ample space for both small and large BOFs as well as impromptu brainstorming sessions. Many conferees stayed at the same hotel, making after-hours ad hoc get togethers easy. And Wisconsin food? I ate my first (and probably last) "bacon bratwurst pretzel burger with cheese."

I gave two sessions. The first was on JavaScript and jQuery in Drupal. The second was on Web Services, mashups and QueryPath in Drupal (a preview version of what I hope to show in Paris this September). Most of the conference sessions are now available in video form.

Update: Added link to QueryPath video

06 May

QueryPath interview with SDR News's Andy McCaskey

in apache, jquery, querypath

Today, SDR News posted Andy McCaskey's full interview with me. In the interview, we talk about the speed of the web, changing development methodologies, and QueryPath.

This interview was filmed at CMS Expo in Evanston.

17 Apr

CMS Expo Presentations

in cmsexpo, javascript, jquery, presentation, querypath

At the end of April, I will be presenting two sessions at the CMS Expo.

Session 1: JavaScript and jQuery

This session will begin with a survey of JavaScript usage. We will then cover jQuery in some detail. From there we will move on to a more general discussion of how CMS systems can benefit from JavaScript integration. The last part of the discussion will discuss some of the new and exciting features in recent browser development, and explore how those are changing the way CMS systems will interact with clients.

Session 2: QueryPath

This session will introduce the QueryPath library. We will see why a library like QueryPath is necessary, what it does, and how it works. I will be showing demonstrations of tools that can be built (quickly) in QueryPath, including Twitter integration, Amazon and SPARQL queries, and a as-of-yet-unveiled mashup featuring an exciting new web service.

15 Apr

IE XMLHttpRequest, RSS feeds, and fixing it with Apache mod_rewrite

in apache, drupal, feeds, ie, javascript, jquery, mime, mod_rewrite, programming, rss, xmlhttprequest

On occasion I have run into a strange problem, both with the RSS JavaScript widget downloadable from aleph-null.tv and with the code I wrote for Drupal 6 JavaScript and jQuery: Under certain conditions, the script simply does not work on IE 6, and IE 7. Firefox, Safari, and such don't seem to have this problem at all.

After a whole lot of digging, I found the problem, and devised a solution that will work out of the box with Apache (and with a little tweaking, it should work with other webservers, too).

18 Mar

jQuery plugin and Drupal module for embedding Flash files

in drupal, javascript, jquery, php, swfembed, swfembed.module

Today, Palantir.net is releasing several module that we built as part of our client work. One of these modules is the SWF Embed module. With this module, developers can create tools that include flash objects.

This module makes use of both PHP code and JavaScript code in order to provide robust Flash integration used in projects like the Flashy Drupal video player. But from a developer's point of view, all you need to do to add Flash support is create an object and theme it. The SWF Embed handbook page describes this process in detail (not that there is a lot to describe).

But there is a hidden gem in there that may come in handy for your non-Drupal sites (if you believe in such a thing).

18 Mar

Precaching images in jQuery: A (slightly) better way

in javascript, jquery, programming

Matt Farina has suggested one method of precaching images using jQuery. But in some applications, this will not give the necessary cache lifetime (at least not in FF3) to warrant the extra network requests. Here, I suggest a slight modification that will make the cache last longer.