Comments (8)
I like more the solution with the data argument.
Also, I think we could add a second (optional) argument to the parseWithFunction option, to send the input name.
The only problem with this would be to explain it properly in the README file without adding too much text/confusion to the plate.
from jquery.serializejson.
I reckon the data arguments should be used to override the form's general options. I.e. correlating parseNumbers: true
on a global level with being able to override it with data-sjson-parse-numbers="false"
.
from jquery.serializejson.
That makes sense. I'll think about it and add an update sometime soon.
Thanks KATT!
from jquery.serializejson.
Got tests added and a beginning of a solution with my parseInputValue
method -- but need to wire it in somehow in a nice way. Ideas?
Will look at it more tomorrow.
from jquery.serializejson.
To solve this problem, I implemented :types
in the version 2.4.0.
Now you can specify a :type
on every input by just appending the type with a colon. This way you can control which input is going to be parsed as string, number, boolean, null, array or object. Which for user-generated values is more safe than using the parse options, that will auto-detect the type to be parsed.
For the example input, the problem could be solved by appending :number
to the input name:
<input type="text" name="Numeric -2.25:number" value="-2.25" />`
from jquery.serializejson.
Mate, you should really do the :type
thing as a data-attribute for the plugin rather than polluting the name
field. 😿
from jquery.serializejson.
I like the idea of
<input type="hidden" name="flags:array" value="[]">
However, I get a bad taste of changing the name
field with plugin specific attributes.
Should be more like:
<input type="hidden" name="flags" value="[]" data-type="array">
from jquery.serializejson.
Yes I know.
When I started implementing the "data-type" stuff I realized that it was going to complicate the code a great deal. It would mean that the plugin would no longer use serializeArray
(because it would need to check field by field), and that is one of the reasons why serializeJSON works so well.
I would not like to compromise the simple case of using serializeJSON
with no options and with same field names used to submit forms to a Rails backend.
Then, I had the idea of "polluting" the name format, because that can still be used with serializeArray
. Well, it makes it more intrusive, and the form is no longer non-javascript compatible. But if someone really wants to change the type of the attribute, the form is already non standard. So it actually doesn't matter to change the field name format.
from jquery.serializejson.
Related Issues (20)
- checkboxUncheckedValue not working for me HOT 1
- Option for include parsed 0 values HOT 1
- Raise ERROR: Invalid type in value HOT 5
- Mixup between colon and semicolon HOT 2
- .serializeJSON returns undefined HOT 4
- Provide dom element into custom type function HOT 5
- Is there something wrong about array? HOT 1
- Make an es6 module? HOT 1
- Ability to use attributes other than name for building the json HOT 3
- Consider passing element name to custom type function. HOT 4
- Versioning scheme? HOT 1
- Empty SELECT multiple HOT 3
- AMAZING, THANK YOU
- It doesn't serialize type=file HOT 3
- Initialize form values from object HOT 3
- Radio Buttons are not working in >3.2.0 HOT 2
- Doesn't work with ASP.NET MVC naming conventions HOT 5
- name多层级数组无效
- checkboxCheckedValue option HOT 1
- Disabled elements are ignored? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery.serializejson.