Skip to content

Instantly share code, notes, and snippets.

@Willian-Zhang
Last active March 18, 2018 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Willian-Zhang/7e5d365be44319afc9aadbe0ff04aadf to your computer and use it in GitHub Desktop.
Save Willian-Zhang/7e5d365be44319afc9aadbe0ff04aadf to your computer and use it in GitHub Desktop.
Extract React Form Data
$('.reactable-data').find('tr').toArray()
.map(tr=>
$(tr).find('td').toArray()
.map(td=>
[$(td).attr('label').replace(',[object Object]',''),
$(td).attr('value') && $(td).attr('value').match('[object Object]') ? $(td).text() : $(td).attr('value')
]
)
.reduce((map, tuple) => {
if(tuple[0] != ' '){
// ignore " "
map[tuple[0]] = tuple[1];
}
return map;
}, {})
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment