Sidetracked: formToArray.js

I was going to work on greeble.rb today, but I got sidetracked - sidetracked in a good way, though.

The options for a decent greeble plugin could be quite long. I started thinking about how to get all the options from a WebDialog to the plugin. I ended up coding up a way to pass an entire HTML form to a script, and create an options hash from the string.

There's 2 parts; the javascript method, and the ruby method. The javascript loops through the html form, building an array of strings in the form "key=value". The array is joined, and passed to SU-Ruby using the window.location= method. The ruby part parses the string and builds a hash from it. It sounds simple in retrospect, but it was a learning experience for me.

I'll post it when I have time to test it in use.

No comments:

Popular Posts (Last 30 Days)