I create my alpaca form with the following syntax:
function createNewAlpacaForm(data, schema, formId, saveButtonId, clickEventFunc) {
$(formId).empty();
$(saveButtonId).off('click');
alpacaForm = $(formId).alpaca({
"data" : data,
"schema" : schema,
"view" : "VIEW_BOOTSTRAP_EDIT",
"postRender" : function(renderedForm) {
clickEventFunc(renderedForm);
}
});
}
This works great, but I now want to update the data dynamically. I have a restore to default button which take my default JSON data and apply it to the form. I take care of this now by completely re-creating the form with the default JSON but this is clunky as the form flickers as it re-creates. Any ideas how to update the JSON data dynamically without re-creating the entire alpaca form?
You can dynamically get the Alpaca form and setValue() similarly to how you use getValue() to retrieve the form values. I think this would work in your case:
$(formId).alpaca('get').setValue(data);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With