redditI came across an issue today with jQuery with multiple forms. I’ve got a page that’s dynamically generating possibly several dozen mostly identical forms on a single page. “Why would you do that?” you might ask. Well, imagine a data set where I want to be able to edit each row independently and you’ve got an idea of what I’m doing. I know it’s not pretty, but it’s definitely an easy and straight forward way to do this. Here’s an example of a typical form that I might have 15 of in this script:
1 2 3 4 5 6 7 8 9 | <form action="/form/process" method="post" class="question_form"> <label for="questiont">Question:</label> <input class="required" type="text" name="question" /> <br /> <label for="answer">Answer:</label> <input class="required" type="text" name="answer" /> <br /> <input type="submit" value="Submit!" /> </form> |
So, you’d think the logical thing to do for quickly running validation on all these forms would be:
1 2 3 | $(document).ready(function() { $(".question_form").validate(); }); |
Unfortunately, because the form fields shared the same name, the validation plugin hiccuped with this solution. Now I’m using custom error classes and rules in my actual implementation, so maybe this problem is more specific and isn’t reproduced quite this easily – but basically what happens is that if you have 10 “Question” forms, the validation plugin will see the “Question” field on the first form and call it good. Obviously, we can’t have that, we want each form validating separately.
The solution? Use the each selector to iterate through the forms, of course:
1 2 3 4 5 | $(document).ready(function() { $(".question_form").each(function() { $(this).validate(); }); }); |
voila! Easy, but I want to remember it for later
Is it sexist that any time someone is piddling along at 5 mph under the speed limit I immediately assume it’s a woman? I think it’s mostly because more often than not that’s exactly the case. Yet every once in a while I’m shocked to discover it’s a man behind the wheel. I justify it to myself when they’re old, asian, or especially if they’re old and asian. But what I really don’t get is when I see a young man between 20 and 40 driving at less than the speed limit for no apparent reason. It’s absolutely mind boggling to me.
As those who’ve ridden with me can attest – I’m a very road ragey driver. I’ll swear and curse any idiot who’s going less than the speed limit anywhere. It’s a fault, I acknowledge it. I should be more patient, and speeding rarely gets you anywhere any faster. Still – if I eventually discover that the person whose existence I’ve been lamenting for several miles is in the aforementioned age bracket, everything I’ve thought about this person is immediately shattered. Replaced not with anger, but utter bafflement and confusion. It’s as if I’ve just discovered a small jungle cat is driving the car.
I don’t see these people often. Most of the time the culprit is exactly the fat old woman who I had channeled all my hatred towards. But once in a while… like this morning… It sets me back.
How am I going to work today?
I swear, it’s not that I haven’t been biking. I’ve been watching older movies and I have no interest in posting them. As soon as I catch a few newer movies I’ll be posting them again.
I’ve got Band Slam (wooohoo!!) and Taking Woodstock coming up soon.
Weight: 212lbs – for the record.
Or Matt’s Movies in Motion! Gay I know, but I mostly like the acronym “MMM”. Basically I’ve been watching a lot of movies lately, and the reason is that I take my little netbook down to the workout room and watch them while I bike. I only do about 45 minutes a session (give or take 10 minutes) but I can get through a movie every two days. I’ve wanted to start posting reviews for a while now, so maybe I can take care of two birds with one stone here and possibly stay motivated on the bike.
For starters I’ll post my weight with each review. If it doesn’t go down I’ll probably stop doing that and just post the reviews
.
Let’s see how long this one lasts!
I should mention here that my rating scale is reflective of the type of movie I’m watching. I might give Ace Ventura: Pet Detective the same rating as the Graduate, but that doesn’t mean I consider the two films to be on equal grounds in quality. My ratings will purely be about how much I enjoyed the movie.
By the way – on my latest trip down to AZ to visit Josh I watched movies there and back on the 2.5 hour flight without recharging the netbook. I fuckin love this thing.
So I’m redesigning ListHippo (it’s gonna be blue/tan and pretty web 2.0-ey. A lot of inspiration from GoodBarry because I think it’s really clean and nice and – that’s another story). Anyway, I’ll usually get little ideas about a design that I like and want to use, but it’s tough to build an entire framework around those little ideas. I usually end up looking around all kinds of sites and checking out smashingmag and templates and stuff to try to find good ways to round it out. In doing so, I came across this this gem:
If I ever have to describe “web 2.0″ to somebody ever again, I’m pointing them here. It’s so web 2.0 that it almost ceases to be anything else. Don’t get me wrong it’s good and functional, but that may be the most forgettable website ever.
Seriously.
http://www.publiceye.org/conspire/flaherty/Federal_Reserve.html
I was going to write this article, but Flaherty has done it much more eloquently and thoroughly than I ever could. I am beyond sick of ignorant idiots spouting bullshit about the Federal Reserve.
On these damn churches started at 8:00 this morning. Then they banged away for a full half an hour . They don’t play music, they just smash random bells as loud as possible. Do you think I’d get anywhere with calling in a noise complaint against a church? I mean there’s no way anyone else could get away with making this much fucking noise.
And oh good, after a 13 minute break they’ve just started up again. I’M UP YOU FUCKERS!