marioizquierdo / jquery.serializeJSON

Serialize an HTML Form to a JavaScript Object, supporting nested attributes and arrays.
MIT License
1.71k stars 433 forks source link

parse single field #85

Closed alexey closed 6 years ago

alexey commented 6 years ago

I have form with conditional updates and sometimes i need to serialize only one field.

i tried: $('#' + elm_id).serializeJSON(); and $('#edit_user #' + elm_id).serializeJSON(); both wit try by class name too..

it works in JS console but not in the code:

var elm = $('#' + elm_id)
console.log('ELM', elm); // return jquery object
var payload = elm.serializeJSON(); 
console.log('PAYLOAD', payload); // return {} 

above works when i run it manually. this code run on document ready and behind other function

alexey commented 6 years ago

OH ! sorry i was disabling input before reading serializeJSON() :) just moved prop disable after serialize :)

Thank you for great library!