Javascript 未捕获的TypeError FormiBuilder不是函数。我做错了什么?
我正在使用Form.io并得到以下错误Javascript 未捕获的TypeError FormiBuilder不是函数。我做错了什么?,javascript,jquery,formbuilder,Javascript,Jquery,Formbuilder,我正在使用Form.io并得到以下错误 Uncaught TypeError: $(...).formiobuilder is not a function 我正试图在我拥有的evrey id上构建一个formbuilder。因此,如果您查看initformbuilder('#fb editor-'+sectionId,JSON.stringify(data))。它调用数据库中的节id。我希望用户可以编辑表单或在表单中添加内容 $(document).ready(function () {
Uncaught TypeError: $(...).formiobuilder is not a function
我正试图在我拥有的evrey id上构建一个formbuilder。因此,如果您查看initformbuilder('#fb editor-'+sectionId,JSON.stringify(data))代码>。它调用数据库中的节id。我希望用户可以编辑表单或在表单中添加内容
$(document).ready(function () {
var formBuilderInstances = [];
$('.section-inner').on('show.bs.collapse', function (e) {
var sectionId = $(this).data('section-id');
var fb = $.grep(formBuilderInstances, function (form) {
return form.id == sectionId;
});
if (!fb[0]) {
var data = forms[sectionId];
var formBuilderInstance = initFormBuilder('#fb-editor-' + sectionId, JSON.stringify(data));
formBuilderInstances.push({id: sectionId, instance: formBuilderInstance});
}
});
});
function initFormBuilder(id, data, content) {
this.formiobuilder = Formio.builder(document.getElementById(this.formiobuilder), {}, {})
if (data) {
options.formData = data;
}
return $(id).formiobuilder(options)
}
答案是。我在哪里找到答案的
您是否尝试过$(id)[0]。FormiBuilder(选项)
?可能行得通。我试过了,但还是犯了同样的错误。谢谢你的帮助
function formiobuilder(){
$(document).ready(function (){
var formBuilderInstances = [];
$('.section-inner').on('show.bs.collapse', function (e) {
var sectionId = $(this).data('section-id');
var fb = $.grep(formBuilderInstances, function (form) {
return form.id == sectionId;
});
if (!fb[0]) {
var data = forms[sectionId];
//HTML
var formBuilderInstance = Formio.builder(document.getElementById('fb-editor-' + sectionId, JSON.stringify(data) ))
formBuilderInstances.push({id: sectionId, instance: formBuilderInstance});
}
});
})
}
window.onload = formiobuilder();