Databridge is a serialization jQuery plugin to read data from forms, and to set data to forms. Supports nested objects, boolean and array checkboxes, on fly data formatting and conversion. Works with any elements with attributes name or data-name, not only inputs.

Download from GIT Hub Download as NPM package


Include script into you page:

<script src="path/to/plugin/mk-databridge.min.js" type="text/javascript"></script>

Basic usage

To set data call databridge with data object


To get data call databridge with no arguments

var dataObject = $('.form-container').databridge();

Data mappers

If you need to convert your data for view, for example, to show timestamp as date string. You can point to mapper function in html attribute data-map="my.mapper.fuction". Mapper function has to return converted value. It takes two arguments: original value and mode (it can be 'set' or 'get'), 'this' variable is set to input element.

Data mappers & DOM manipulation

Mapper function gets this variable set to input element, so you can control it from mapper for additional effects.

Effects with mappers

You can create special views this way.

Nested objects

You can use nested objects with either 'dot'-notation or 'square-brackets'-notation.

Download from GIT Hub Download as NPM package