我正在尝试以编程方式处理 Jquery UI 手风琴的切换我希望如果有人单击下一步按钮然后在添加隐藏字段后进入下一步这是我在代码中编写的内容:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Pro Plan Store</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script>
$(document).ready(function(){
$("#changeStep").on("click",function(){
$("#step1content").append("<input type='hidden' name='step1done' id='step1done' value=''>");
$('#accordion').accordion('option', 'active', 1);
});
var accordian = $( "#accordion" ).accordion({
active: false,
beforeActivate: function(event, ui) {
var newIndex = $(ui.newHeader).index('h3');
console.log(newIndex);
switch(newIndex){
case 0:
// $(this).accordion( "option", "active", 0 ); //Main page just set it to homepage again
break
case 1:
if($("#step1done").length > 0){
$(this).accordion( "option", "active", 1 ); //Main page just set it to homepage again
}
else{
alert("Please login first to choose plan");
event.preventDefault();
}
break
case 2:
break
}
}
});
});
</script>
</head>
<body>
<div id="accordion">
<h3 id="logmein">Welcome Pro Plan Store</h3>
<div id="step1content">
<p>
Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer
ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit
amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut
odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.
</p>
<input type="button" value="Next" id="changeStep" />
</div>
<h3 id="chooseplan">Choose Plan</h3>
<div id="step2content">
<p>
Choose Plan Here
</p>
</div>
<h3 id="zoura">Checkout</h3>
<div id="step3content">
<p>
Zoura Iframe
</p>
</div>
</div>
</body>
</html>
但是当我运行它并在控制台中看到它时,它给了我太多的递归错误。如以下错误所示:
难道我做错了什么??我正在使用所有稳定版本的库。我还通过模拟手风琴头部元素的点击来尝试它,但我得到了同样的错误