In the web community
Prototype is a "must" for who wants to implement unobstrusive javascript and web2.0 applications. Why? 'Cause prototype makes things simplest and more Object Oriented.
The fact is that Javascript is often used as a "functional language" and not Object Oriented. Maybe because Javascript is not a clean OO language or maybe because, for historical reasons, people used it to handle (most of the time) the "onclick" event...
With the revolution of these days, javascript is becoming a way to enhance the user experience in web applications (take
Ajax for example...).
So here's it: Prototype is coming to help us develop web2.0 application, using Objects in a more simple way, introducing classes for Ajax integration and much more. Maybe one of these days I'll write a good
Prototype in Action post, but for the moment use this link as reference:
http://www.sergiopereira.com/articles/prototype.js.htmlUpdate: now Prototype has its own official documentation. Read it here:
http://www.prototypejs.org/learn.
Ok...now that you have "the tool" let's see an interesting feature: with prototype you can serialize a form given its id with a simple call:
var serializedForm = Form.serialize('myform');
This function allow you transform a form in a encoded string, containing all values from the passed form.
Ok, now you can save your form (for example via AJAX on your server...), but what you can do if you want to deserialize back it to your client? No way with the current version of Prototype (1.4)!
So I wrote a simple extension to allow you deserialize forms given a serialized string.
Here is a simple example:
The call to the function is simple:
Form.deserialize(formElement, serializedString)
You can find the .js file
here A complete example can be downloaded
here