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 pletely 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?
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 pletely 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?
Share Improve this question edited Aug 10, 2015 at 13:01 Jacob van Lingen 9,5977 gold badges54 silver badges83 bronze badges asked Jun 10, 2014 at 16:52 Michael LoCiceroMichael LoCicero 4431 gold badge6 silver badges12 bronze badges 3- Why arew you using $(saveButtonId).off('click'); – Jain Commented Jun 10, 2014 at 17:00
- I have a select box with an ID which generates different alpaca forms on select. Each form uses the same saveButton(i.e. button input). I pass the button inputs on click event function to the createNewAlpacaForm which is used in the postRender callback. I need to clear the buttons on click event function mapping each time before setting it again in this createNewAlpacaForm function. – Michael LoCicero Commented Jun 10, 2014 at 20:19
- Does not really pertain to my question, but I answered anyway :) – Michael LoCicero Commented Jun 10, 2014 at 20:20
1 Answer
Reset to default 7You 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);
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744965122a4603629.html
评论列表(0条)