简体   繁体   English

jQuery手风琴无法使用Javascript创建的内容

[英]JQuery accordion not working with Javascript created content

I am looking to use a form to add items to an array in Javascript and then use he values to be displayed in accordion. 我正在寻找一种使用表单将项目添加到Javascript数组中,然后使用其值来显示手风琴的方法。

However, when I create a string of the values and add them to the HTML file, the accordion doesn't work. 但是,当我创建一个值字符串并将其添加到HTML文件时,手风琴不起作用。 It is in exactly the same format when it is added than when it is entered manually. 添加时的格式与手动输入时的格式完全相同。

When I enter the same code manually, the accordion works no problem 当我手动输入相同的代码时,手风琴工作正常

Any Ideas? 有任何想法吗?

Thanks 谢谢

Code to create string: 创建字符串的代码:

contact.prototype.contactList= function(){
var cl = "<h3>" + this.firstname + "</h3><div><p>" +
         this.middlename + "" + this.lastname + "" + this.homeadd1 + ""+ this.homeadd2 + ""+ this.homeadd3 + ""+ this.homepost + ""+ this.workadd1 + ""+ this.workadd2 + ""+ this.workadd3 + ""+ this.workpost + ""+ this.email + ""+ this.homephone + ""+ this.workphone +""+ this.mobilephone +""+ this.dob +""+ this.relstat +"</p></div>";

return cl;

}; };

JS Accordion Function: JS手风琴功能:

$('#accordion').on('update', 'h3', function() {
            $( "#accordion" ).accordion();
        });

The id I am adding the content to is called accordion 我要添加内容的ID称为手风琴

Thanks in advance for your help 在此先感谢您的帮助

Check API of jqueryui. 检查jqueryui的API。

Maybe you need to use refresh. 也许您需要使用刷新。

http://api.jqueryui.com/accordion/#method-refresh http://api.jqueryui.com/accordion/#method-refresh

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM