admin管理员组文章数量:1406060
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);
本文标签: jqueryalpaca javascript dom updateStack Overflow
版权声明:本文标题:jquery - alpaca javascript dom update - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744965121a2634897.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论