my prototype cheat sheets: forms

I was having problems this morning with Prototype, in getting serialized forms, so I went back to this little cheat sheet that I wrote up once and updated it and figured out what the problem was.  I uploaded my cheat sheet to my website, if anyone wants to see it.

If you’ve used Prototype for JavaScript before, then you might know where I’m coming from.  In my opinion, the library is awesome, but the documentation is a little confusing in some places.  It could be that way for me only because I’m still so new to JavaScript.  Anyway.  I know for certain that writing this stuff out this way totally helps explain it for me, being a kinesthetic learner.

The problem I ran into recently, though, with Prototype was that it’s unclear what happens when you serialize an element.  The docs say that it returns an object … but it’s not a Prototype Object, meaning you can’t run functions on it that are attached to that.  It’s certainly not a Hash, either, since you can’t use those functions either.  Not knowing JavaScript much, I assume it’s just a regular JavaScript object.

Either way, to convert it to a JSON-formatted string, you need to cast the serialized element to an Object or a Hash of Prototype design first.  That’s what was tripping me up, and that’s the final section on that forms cheat sheet.

I’m using Prototype a lot more at work.  I’m building an intranet at work that is going to use a lot of AJAX, and so I really need to polish my skills.

Wow, this post is boring.  It needs some unicorns.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s