Posted At : May 18, 2010 3:47 PM | Posted By : Bob Silverberg
Related Categories:
jQuery
I'm still a relative noob when it comes to jQuery, so today, when I had a need to check whether a particular form field existed, I had no idea how to do it.
Of course some quick Googling brought me an answer,
from the jQuery for Designers site by
Remy Sharp.
The quick answer is that you can test the length property of any jQuery object, and if it returns zero then the element
doesn't exist. For example, what I wanted to do was to disable a form field if another form field existed, so I wrote the following code:
if ($("#fieldA").length != 0) {
$("#fieldB").attr("disabled", "disabled");
}
Reading through the comments on that page,
I saw a suggestion by Kat Reeve to add the following to a standard JavaScript include file:
jQuery.fn.exists = function() { return (this.length > 0); };
Which would allow me to change the above code to:
if ($("#fieldA").exists()) {
$("#fieldB").attr("disabled", "disabled");
}
Nice, innit?
Posted At : May 12, 2009 10:33 AM | Posted By : Bob Silverberg
Related Categories:
ColdFusion,jQuery
Because my ColdFusion driven Twitter/Google Maps Mashup is so slow, I decided that it would be nice to have a dynamic progress bar, which updates the status as each of the user's friend's addresses are being looked up. I knew that the jQuery UI project has a Progressbar widget, so I did a quick Google for "jQuery Progressbar ColdFusion", and, no big surprise, came across a blog post by Ray Camden on the topic. That was enough to get me started, but Ray didn't cover creating a dynamic progress bar that is updated by the currently running page.
I figured that I could build something using cfflush, and I was not mistaken. Here's a summary of what I did:
[More]
Posted At : October 2, 2008 6:47 AM | Posted By : Bob Silverberg
Related Categories:
jQuery
I've been using jQuery for about a year now and I must admit that pretty much any JavaScript that I wrote prior to that looks ugly to me now. I know I'm nowhere near the first person to say this, but if you write JavaScript and you aren't using jQuery, you should check it out. Now.
Anyway, I wanted to show you how easy it is to do something cool with jQuery. The next thing I'll admit is that much of what I'm doing with jQuery involves using existing plugins written by other, more seasoned JavaScripters than me. But enough talk, here's the table:
[More]