jonathansp / jquery-serializefields Goto Github PK
View Code? Open in Web Editor NEWjQuery plugin to serialize form elements into a JSON object using fieldsets.
License: GNU General Public License v2.0
jQuery plugin to serialize form elements into a JSON object using fieldsets.
License: GNU General Public License v2.0
Add support to select and multiple select inputs.
Look that test:
QUnit.test("When form has select input it should get value from selected", function(assert) {
// given
var form = '<form>'+
'<select name="carlist">'+
' <option value="volvo" selected>Volvo</option>'+
' <option value="saab">Saab</option>'+
' <option value="opel">Opel</option>'+
'</select>'+
'</form>';
// when
var result = $(form).serializeFields()
// then
assert.equal(result.carlist, "volvo", "Property carlist has value Volvo!")
});
Not sure if its something to do with my setup, or if there is an actual issue with IE 11 support but..
the serialiserializeFields
method gathers all the data into a JSON object, but doesn't group by the fieldset
names. All the keys are at the same level.
Anybody had experience with this? Cheers
P.S. a client uses IE not me!
When parsing checkbox input it get value even if checkbox is not checked. I think the best solution for that case is:
See that test case:
QUnit.test( "When form has checkbox it should get value only from 'checked'", function( assert ) {
// given
var form = '<form>'+
' <input type="checkbox" name="check1" value="true" checked/>'+
' <input type="checkbox" name="check2" value="true"/>'+
' <input type="checkbox" name="check3" value="true"/>'+
'</form>';
// when
var result = $(form).serializeFields()
// then
assert.equal(result.check1, "true","Property check1 has value!")
assert.ok(!wasDefined(result.check2),"Property check2 was not defined!")
assert.ok(!wasDefined(result.check3),"Property check3 was not defined!")
});
It should make sure that all tests are ok before executing npm publish.
Add bower instructions
bower install jquery-serializeFields
More details can be found here:
http://bower.io/docs/creating-packages/#register
Remove parse function from inside $.fn.serializeFields.
Please update tag for last version. That way bower can show the right version.
๐
It get the last value from a Radio input.
Look this test case:
QUnit.test("When form has radio button input it should get value from checked", function(assert) {
// given
var form = '<form>'+
+'<input type="radio" name="sex" value="male" checked>Male'
+'<input type="radio" name="sex" value="female">Female'
+'</form>';
// when
var result = $(form).serializeFields()
// then
assert.equal(result.sex, "male", "Property sex has value male!")
});
Create a way to ignore fields by tag like:
<fieldset name="contact">
<input type="text" name="email" value="[email protected]" />
<fieldset name="phones">
<input type="text" name="primary" value="+55 51 123456789" />
<input type="text" name="mobile" value="+55 51 987654987" />
<!-- ignore this field -->
<input data-ignored-field="true" hidden type="text" name="my_ignored_field" value="nothing" />
</fieldset>
</fieldset>
Thxs
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.