form2js icon indicating copy to clipboard operation
form2js copied to clipboard

Same as https://github.com/marioizquierdo/jquery.serializeJSON

Open marioizquierdo opened this issue 10 years ago • 7 comments

I know this is not an issue but I didn't know how to send you a message.

I noticed that this library solves exactly the same problem I solved on my jquery.serializeJSON plugin.

I am also surprised that we both decided to format the fields as in Rails.

I will add a reference to this repository from my README file as the "no jQuery" solution ;)

marioizquierdo avatar Jan 08 '14 03:01 marioizquierdo

since you have 0 issues in your project Github and this form2js one has 40..I will use serializeJSON. make so sense using a neglected code. thanks for posting this!

yairEO avatar Mar 30 '14 22:03 yairEO

@marioizquierdo your jquery.serializeJSON plugin works extremely well and is well documented but lacks a few features offered by form2js. Namely, for my typical usage, the getDisabled option and the handling of checkboxes. In your documentation you show a workaround for checkboxes, but since 985a3f3214 such a workaround is not necessary with form2js.

endeavor85 avatar Aug 25 '14 16:08 endeavor85

I don't have plans to support such a feature. jquery.serializeJSON is built on top of jquery.serializeArray, which is one of the reasons why the code is so stable. The .serializeArray() method uses the standard W3C rules for successful controls, to determine which elements it should include; in particular the element cannot be disabled and must contain a name attribute. The idea is to be as W3C compliant as possible, even if it requires creating some common "gotchas". At least they are the same gotchas as any other web form.

marioizquierdo avatar Aug 25 '14 17:08 marioizquierdo

Understood. So it would seem the usage scenarios are a bit different then. This project may deviate from W3C compliance in order to satisfy various (perhaps non-standard) requirements. Nonetheless, I appreciate your contribution as it seems to solve its problem.

endeavor85 avatar Aug 25 '14 17:08 endeavor85

Yes, the confusion with the checkboxes is actually pretty common. I blame the W3C standard ;)

marioizquierdo avatar Aug 25 '14 18:08 marioizquierdo

@endeavor85 I was thinking a little more about how common is the checkbox problem and I came up with a solution that is not obtrusive.

By default, serializeJSON still does not include unchecked checkboxes, but from version 2.2.0, the attribute data-unchecked-value can be used to make it work without hidden fields:

<input type="checkbox" name="show" value="true" data-unchecked-value="false">

Also, the new option checkboxUncheckedValue could be used to use a default value for all unchecked checkboxes without having to repeat the data-unchecked-value over and over again in the HTML.

Thank you for your feedback!

marioizquierdo avatar Sep 17 '14 14:09 marioizquierdo

Nice, that's a much more elegant approach

endeavor85 avatar Sep 17 '14 15:09 endeavor85