Skip to content

Commit

Permalink
fix: onSave not called when save called from the api
Browse files Browse the repository at this point in the history
resolves #1058
  • Loading branch information
kevinchappell committed Aug 23, 2020
1 parent d41f3a3 commit d607b02
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/demo/js/actionButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export const builderActions = {
window.sessionStorage.setItem('formData', value)
$('.build-wrap').formBuilder('setData', value)
},
save: () => {
$('.build-wrap').formBuilder('save')
},
addField: () => {
const field = {
type: 'text',
Expand Down
1 change: 1 addition & 0 deletions src/demo/js/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ jQuery(function($) {
getJSON: 'Get the current formData in JSON format',
getJS: 'Get the current formData in JS object format',
setData: 'set the current formData value for the editor',
save: 'call save from the api',
toggleAllEdit: 'toggle the edit mode for all fields',
toggleEdit: 'toggle a specific field edit mode by index or id',
addField: 'programmatically add a field to the template editor',
Expand Down
5 changes: 4 additions & 1 deletion src/js/form-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,10 @@ const FormBuilder = function(opts, element, $) {
activeOnly ? subtract(controls.getRegistered(), opts.disableFields) : controls.getRegistered(),
clearFields: animate => h.removeAllFields(d.stage, animate),
showData: h.showData.bind(h),
save: h.save.bind(h),
save: minify => {
h.save(minify)
config.opts.onSave(h.getFormData())
},
addField: (field, index) => {
h.stopIndex = data.formData.length ? index : undefined
prepFieldVars(field)
Expand Down

0 comments on commit d607b02

Please sign in to comment.