Javascript / DHTML Web Log Entries
jQuery's Closest() Method Returns Only One Ancestor
Posted: October 6, 2009 at 9:31 AM by Ben Nadel
If you need to get an anscestor of a given element, jQuery's parents() method is really useful. Not only will it crawl up through the DOM tree, it allows you to supply a jQuery selector that can filter the collection of parent nodes that is returned. This works in most cases; however, when the anscestor or parent that you are looking for depends o... read more »
Comments (11) | Post Comment | Ask Ben | Permalink
Viewing jQuery DOM Event Bindings With FireBug
Posted: October 5, 2009 at 10:27 AM by Ben Nadel
The ease with which we can bind events to DOM elements using jQuery is a huge part of what makes jQuery so awesome. But, as with many things that are wired-up programmatically, when something doesn't work, it can be hard to figure out where it went wrong. One cool tip that I picked up reading Cody Lindley's jQuery Enlightenment book is that jQue... read more »
Comments (9) | Post Comment | Ask Ben | Permalink
jQuery's is() Method Checks For Any Matching Elements
Posted: October 1, 2009 at 2:14 PM by Ben Nadel
This is a really tiny post, but just something that I wanted to point out. The is() method in jQuery will return true if any of the elements in the current collection match any of the elements in the is-based collection (as defined by the given selector). Normally, if you're working with just a single element, there's no problem; but, if your curr... read more »
Comments (9) | Post Comment | Ask Ben | Permalink
Using Javascript's IN Operator To Test For Object Property Existence
Posted: October 1, 2009 at 9:05 AM by Ben Nadel
A small, but powerful tip that I picked up while reading Cody Lindley's jQuery Enlightenment book , was the use of Javascript's IN operator to test for object property existence. Before that, I had only ever used the IN operator to iterate over an object's keys, as in: for (var key in myObject){ // ... key is iteration index value ... } T... read more »
Comments (8) | Post Comment | Ask Ben | Permalink
jQuery's Filter() Method Can Take A Callback Function For Advanced Filtering
Posted: September 25, 2009 at 10:07 AM by Ben Nadel
I think one of the most awesome tips that I picked up while reading Cody Lindley's jQuery Enlightenment book was that the filter() method can take a callback function as its argument. Typically, when I use jQuery's filter() method, I simply pass in a selector that it would then use to narrow down the collection of DOM elements: var items = $(... read more »
Comments (6) | Post Comment | Ask Ben | Permalink
jQuery's Passes Itself As An Argument To The "Ready" Event Callback
Posted: September 24, 2009 at 3:02 PM by Ben Nadel
As I read through Cody Lindley's excellent jQuery Enlightenment book , I found myself dog-earing many pages that contained little tips and factoids that I had never seen before. One of these facts was that jQuery passes itself as an argument to the callback methods that you provide in the "ready" event bindings. While this might not seem at first... read more »
Comments (3) | Post Comment | Ask Ben | Permalink
Ask Ben: Displaying A Blog Teaser (Showing The First N Words)
Posted: September 23, 2009 at 10:22 AM by Ben Nadel
Hi Ben, I am writing from London, United Kingdom. How can I display the first 50 words of a blog post as a teaser using some jQuery code snippet? I gotta follow you on twitter. cheers. I know you asked to see this as a jQuery code snippet - and I will get to that - but first, I want to approach this from a ColdFusion view point. I think it makes ... read more »
Comments (32) | Post Comment | Ask Ben | Permalink
Ask Ben: Excluding Script Tag Content From The jQuery .text() Method
Posted: September 22, 2009 at 9:26 AM by Ben Nadel
Hi Ben, I have come across an issue with jQuery when using "text().length" and I am hoping that you may be able to help. I have applied a CSS class called hideEmpty to a div. I am then using jQuery text().length to provide the total length of that element, including child nodes, and hiding it if it is low. This works very well in most situations b... read more »
Comments (7) | Post Comment | Ask Ben | Permalink
jQuery Enlightenment By Cody Lindley
Posted: September 18, 2009 at 8:50 AM by Ben Nadel
As an attendee of the jQuery Conference 2009, I received a free PDF version of Cody Lindley's new book, jQuery Enlightenment . The jQuery conference was tremendously inspiring, so needless to say, I returned from it ready to devour some tasty jQuery goodness. And, devour it I did; I got through jQuery Enlightenment in three nights, no problem. ... read more »
Comments (22) | Post Comment | Ask Ben | Permalink
Returning An Array From jQuery's Map() Utility Function
Posted: September 16, 2009 at 8:37 AM by Ben Nadel
Yesterday, when I was building my jQuery selector step-debugger plugin , I was having some trouble with the jQuery map() utility method. I was trying to map (translate) one array into another, in which the resultant array value was, itself, an array; I thought this would simply insert the return array value as a single index in the mapped array c... read more »
Comments (2) | Post Comment | Ask Ben | Permalink
jQuery Plugin: Tracing Your Selector Paths
Posted: September 15, 2009 at 2:25 PM by Ben Nadel
A while back, I wrote a proof-of-concept about enabling step-debugging in your jQuery selector paths . In that previous demo, you had to enter your jQuery selector values into a form and execute it manually within the test environment. This morning, I took that same concept and rolled it into a jQuery plugin. The plugin both lives as a utility fu... read more »
Comments (7) | Post Comment | Ask Ben | Permalink
Ask Ben: Keeping Close Track Of Who Is Currently Online
Posted: August 27, 2009 at 10:03 AM by Ben Nadel
Hi Ben, I am trying to attempt to have a "current users online" type of functionality for my company's webportal. I am using a application variable such as "application.useronline" which is a list that contains usernames as they login to my portal. As they sign off or when their session times out, a page runs that flushes all their session variabl... read more »
Comments (14) | Post Comment | Ask Ben | Permalink
The Regular Expression Cookbook By Steven Levithan And Jan Goyvaerts
Posted: July 27, 2009 at 9:35 AM by Ben Nadel
A few weeks ago, I was super excited to learn that regex ninja Steven Levithan coauthored the new O'Reilly book, Regular Expression Cookbook with Jan Goyvaerts. If the name Steve Levithan sounds familiar it's because Steve is a long time participant on this blog, often swooping in to demonstrate his crazy regular expression skills, pointing ou... read more »
Comments (10) | Post Comment | Ask Ben | Permalink
Creating Readable SQL Statements In AIR (Adobe Integrated Runtime)
Posted: July 24, 2009 at 5:32 PM by Ben Nadel
Last night, Jason Dean was awesome enough to hold a Connect session with Andy Matthews , Todd Rafferty , and myself in which he demonstrated how to build an HTML and jQuery powered AIR application . It was an awesome presentation and really opened my eyes. Jason has gotten me totally excited about playing with AIR. One thing that I mentioned ... read more »
Comments (5) | Post Comment | Ask Ben | Permalink
Step Debugging jQuery Selectors
Posted: July 16, 2009 at 11:00 AM by Ben Nadel
NOTE : This blog post was inspired by a post that Ray Camden did a while back about an AIR-based jQuery selector tester . I was talking to some people a while back about debugging jQuery selectors. To me, the hardest part about debugging jQuery selectors is that when they are not returning the set of nodes you want, or nodes at all, its ha... read more »



