13 comments

[ 4.5 ms ] story [ 50.7 ms ] thread
Why do we keep rewriting libraries like this? We were writing the exact same thing at one of my previous jobs back in 2010.
the point of the library is so it doesnt get rewritten - did you open source what you did before?
HOT TAKE - code reuse is good and all that, but I think there's a pressure to produce "open source" code that causes people to publish things that might be useful to them but are not entirely relevant.
Isn't it fair to any developer to just share what he/she has created all by themselves with the outside community ? I wanted to do the same, guys.
Yes, that's the point I'm making. You can currently find dozens upon dozens of the same in NPM: https://www.npmjs.com/search?q=form+serialize
Thanks for sharing this link, I have however used this library. Things that I did not like in this because of the following reasons

1. I cannot put the values of one object inside the other unless they come under the same parent.

2. Arrays in my case can be created in one go and you need not specify the array indexes hard coded in the html itself.

3. In my case some inputs were not inside any forms. This library mandates that it should be so it did not work for me.

I understand my code will be far less sophisticated but I made it to solve a problem and learn javascript as well. I did and wanted to see how many others face the same problem and can use it.

It is on github for over an year now. I was working on my own startup that time and hence could not get much time to publish it here. Now I had time so publishing here to get feedback on it.
I didn't really look too closely at this library, but I do have a need for some heavy form processing (not so much validation) on a new project I am working on. Got any recommendations?
Would you give it a try @esaym and maybe if possible do share your issues. May be I can add something new to my library.

Here is a list of even more sophisticated libraries that might help you as well

https://www.npmjs.com/search?q=form+serialize

Someone already posted this link earlier here.

I agree with you, but I was learning javascript and wanted to write something with it that could solve my form related problem. I tried using some libraries but some had bad notations and some did not work as expected. I wrote it on my own and thought to share it with people who have gone far beyond in js and get their feedback. That is why I shared it.
I may be missing something (I am an amateur dev) but isn't this made easy with Vue?

I use it when I need to process a form and just send the relevant "data" part (or all of "data") upon "sumbit" being fired off.

This works for non-form elements as well which was a necessity in my case.
When looking at your example, I see <input> (various types). If you bind these in Vue, you can send them upon some kind of event (a submit button, a click on a div, the value of some variable,...).