http://plugins.jquery.com/project/Values

Think of this as val() crossbred with serializeArray() and raised on
steroids.  Or a JSON<->HTML mapping tool.  Or a template plugin that
can handle complex data structures, works in reverse and uses only
HTML as its syntax.  It works with single values.  It works with value
arrays.  It works with whole objects.  Or all three combined.  Oh, and
did i mention that it is really easy to configure and/or extend?
Flexibility abounds, but it mostly just works, making your code robust
and simple.  Just remember, it has a generic name, because it is
generally useful (and values() makes more sense as a method than
mycoolpluginname()).

Here's a little demo of some of the simpler abilities:
http://jquery-values.googlecode.com/svn/trunk/jquery.values.htm
Here's a link to the latest version:
http://jquery-values.googlecode.com/svn/trunk/jquery.values.js

If you're curious about how it works but don't feel like reading the
docs, here's the short version:
- Put a name attributes on an element (any, not just input/select/textarea)
- Call values() on that element (or a parent!!  this is a key part!)
to get back a JSON version.
- Call values(myJSON) on that element to push values into the element(s)
- Call values('foo') to get just the one value.
- Call values('foo', 'bar') to set just the one value.

This all works well with nested objects and arrays too.  After all,
the world is not flat; your data (or markup) shouldn't have to be
either.  Both JSON and HTML contain a lot of information in their very
structure and types.  Values takes advantage of this to make
intelligent choices about how to map one to the other.  If you ever
disagree about those decisions or want to amend them, there's quite a
few configuration options and ways to extend the plugin to handle new
element types or just handle familiar ones differently.

If you are using javascript to do anything more than make your pages
do shiny animations, you have probably come across the need to write
data into a page, extract data from your markup or just copy data
around the page.   jQuery's html(), text(), val() and even attr()
methods are handy, but they only do so much for you.  You still have
to select the right elements to get/set the data and know which method
is appropriate.  In development especially, when your markup and/or
data structures are frequently changing, this can become a pain point.
 Or even if it doesn't pain you, values() is a better way!

Anyway, give it a try!  It's fun!  It's easy!  Everyone is... wait...
no, everyone is not doing it. At least, not yet.  That's why i'm
writing this.  I think i've got something helpful here, and i'd like
to share.  I want all the joy and ego validation that having many
users brings.  But more than that, i want bug finders.  I want bug
fixers.  I want help with docs and demos and extensions.  I want good
user questions.  I want YOU!

So, give it a try and send me some feedback.  I can handle the abuse
(i hope).  Just reply to this email or write the list with [Values] in
the subject so that i notice you.

thanks,
nathan

Reply via email to