javascript - How to pass dynamic items and properties to JS constructor function? -
i struggling correct syntax iterating through array pass properties (and number of items) external js constructor function.
the syntax constructor is:
`swal.withform({ formfields: [ { id: 'x', type:'y', name:'z', value:''}, {etc...} ] })`
but let's number of formfields dynamic, , stored in array. how can iterate through inside constructor function? or there way "paste" externally created syntax function?
hope question makes sense.
do mean want populate formfields
array dynamic data?
if should it.
var myfields = []; myfields.push({ id: 'x1', type:'y', name:'z', value:''}); myfields.push({ id: 'x2', type:'y', name:'z', value:''}); myfields.push({ id: 'x3', type:'y', name:'z', value:''}); swal.withform({ formfields: myfields })
you build array using loop or map function if have array need convert formfields
array.
Comments
Post a Comment