DuplicateElement icon indicating copy to clipboard operation
DuplicateElement copied to clipboard

How to save all values in an Array of objects?

Open muhfred opened this issue 8 years ago • 1 comments

Thank you for this plugin, it's awesome, can you please tell me how to loop through all elements and push them to an array of objects?

`var Object = []; $("#save").on('click', function(){

var fieldaTxt = $("#field-a").val();

var fieldbTxt = $("#field-b").val();

var fieldcTxt = $("#field-c").val();

Object.push({

"fieldA":fieldaTxt,

"fieldB":fieldbTxt,

"fieldC":fieldcTxt

}); 

console.log(Object);

});` Thank you.

muhfred avatar Jul 21 '17 22:07 muhfred

Use onCreate && onRemove callback methods to add && remove value to your object

Example:

var collection = [];
***
onCreate: function (el) {
***
collection.push( el.find("input").val()); 
***
}

fire1 avatar Jul 24 '17 06:07 fire1