jQuery UI 手风琴嵌入式表单重命名标题
我想在我的手风琴中嵌入一个表单。我希望用户能够编辑手风琴的内容。手风琴的内容部分工作正常,但是当我尝试编辑手风琴的标题时,我无法插入空格(当我按下空格时,当前选定的内容面板会折叠)。我猜这与标头是由 块定义的事实有关,但我不明白为什么按空格键很重要或如何来解决这个问题。
function makeAccordion(){
var stop = false;
$("#accordion h3").click(function(event){
if (stop) {
event.stopImmediatePropagation();
event.preventDefault();
stop = false;
}
});
$("#accordion").accordion({
header: "h3"
}).sortable({
axis: "y",
handle: "h3",
stop: function(event, ui){
stop = true;
}
});
}
<body>
<div id="accordion">
<form action="" method="post">
<div id ="1">
<h3 id ="h3_1"><a href="#">Step Name: <input type="text" name="stepName"></a></h3>
<div id ="content_1">
Step: <input type="text" name="content">
</div>
</div>
</form>
</div>
</body>
谢谢!
I want to embed a form in my accordion. I want a user to be able to edit the contents of the accordion. Things work fine for the content section of the accordion, but when I try to edit the header of the accordion I can't insert spaces (and when I do press space the currently selected content panel collapses). I'm guessing this has something to do with the fact that the header is defined by a <a></a>
block, but I can't think why pressing space bar matters or how to get around the issue.
function makeAccordion(){
var stop = false;
$("#accordion h3").click(function(event){
if (stop) {
event.stopImmediatePropagation();
event.preventDefault();
stop = false;
}
});
$("#accordion").accordion({
header: "h3"
}).sortable({
axis: "y",
handle: "h3",
stop: function(event, ui){
stop = true;
}
});
}
<body>
<div id="accordion">
<form action="" method="post">
<div id ="1">
<h3 id ="h3_1"><a href="#">Step Name: <input type="text" name="stepName"></a></h3>
<div id ="content_1">
Step: <input type="text" name="content">
</div>
</div>
</form>
</div>
</body>
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了一个可行的解决方案,但我不确定后果。
在 jquery.ui.accordion.js 中:
注意从空格到输入的“跌落”。我添加了一个中断:
按“enter”键您仍然可以获得关闭行为,因此如有必要,也可以随意中断。我认为问题出在
,但我在第一次阅读时没有看到它。这个编辑对我有用。
希望有帮助
I found a working solution, but I'm not sure of the consequences.
In jquery.ui.accordion.js:
Notice the "fall through" from space to enter. I added a break:
You still get the closing behavior on pressing "enter", so feel free to break there if necessary as well. I think the problem is in
but I didn't see it on my first read through. This edit works for me.
Hope that helps