Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何处理可排序手风琴中的项目发布事件?_Javascript_Jquery - Fatal编程技术网

Javascript 如何处理可排序手风琴中的项目发布事件?

Javascript 如何处理可排序手风琴中的项目发布事件?,javascript,jquery,Javascript,Jquery,在jQueryUI中,如何处理项目发布事件? 我试过这个: $('#accordion').mousedown(function() { alert('Handler for .mousedown() called.'); }); 但结果并不正确。物品总是粘在鼠标上。。。鼠标按下时,弹出窗口显示,如果单击“确定”,则该项目仍会粘在鼠标上 <!DOCTYPE html> <html> <head> <meta http-e

在jQueryUI中,如何处理项目发布事件? 我试过这个:

$('#accordion').mousedown(function() {
    alert('Handler for .mousedown() called.');
});
但结果并不正确。物品总是粘在鼠标上。。。鼠标按下时,弹出窗口显示,如果单击“确定”,则该项目仍会粘在鼠标上

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>jQuery UI Example Page</title>
        <link type="text/css" href="css/ui-lightness/jquery-ui-1.8.23.custom.css" rel="stylesheet" />
        <script type="text/javascript" src="js/jquery-1.8.0.min.js"></script>
        <script type="text/javascript" src="js/jquery-ui-1.8.23.custom.min.js"></script>

        <style>
        /* IE has layout issues when sorting (see #5413) */
        .group { zoom: 1 }
        </style>
        <script>
        $(function() {
            $( "#accordion" )
                .accordion({
                    header: "> div > h3"
                })
                .sortable({
                    axis: "y",
                    handle: "h3",
                    stop: function( event, ui ) {
                        // IE doesn't register the blur when sorting
                        // so trigger focusout handlers to remove .ui-state-focus
                        ui.item.children( "h3" ).triggerHandler( "focusout" );
                    }
                });
        });


        function show_progress() {
            var items = $('.group', '#accordion');
            for(var i=0; i<items.length; i+=1) {
                alert(items[i].innerHTML);
            }
        }


        </script>

        <div id="accordion">
            <div class="group">
                <h3><a href="#">Section 1</a></h3>
                <div>
                    <a href="#">Edit Item</a>
                    <span class="svr_rlv_url"></span>
                </div>
            </div>
            <div class="group">
                <h3><a href="#">Section 2</a></h3>
                <div>
                    <a href="#">Edit Item</a>
                    <span class="svr_rlv_url"></span>
                </div>
            </div>
            <div class="group">
                <h3><a href="#">Section 3</a></h3>
                <div>
                    <a href="#">Edit Item</a>
                    <span class="svr_rlv_url"></span>
                </div>
            </div>
            <div class="group">
                <h3><a href="#">Section 4</a></h3>
                <div>
                    <a href="#">Edit Item</a>
                    <span class="svr_rlv_url"></span>
                </div>
            </div>
        </div>

        <br/>

        <a href="#" onclick="show_progress();">CLICK</a>

        <script>
            $('#accordion').mousedown(function() {
              alert('Handler for .mousedown() called.');
            });
        </script>

    </body>
</html>

jQueryUI示例页面
/*IE在排序时存在布局问题(请参见#5413)*/
.group{zoom:1}
$(函数(){
$(“手风琴”)
.手风琴({
标题:“>div>h3”
})
.可排序({
轴:“y”,
手柄:“h3”,
停止:功能(事件、用户界面){
//IE在排序时不注册模糊
//因此,触发focusout处理程序以删除.ui状态焦点
ui.item.children(“h3”).triggerHandler(“focusout”);
}
});
});
函数show_progress(){
变量项=$(“.group”,“accordion”);

对于(var i=0;i您不应该在脚本中间警告),这就是脚本中发生的事情:

  • 鼠标按下-项目可拖动
  • 警报-javascript暂停
  • 释放鼠标单击ok,但javascript不知道这一点,因为脚本已暂停
  • 当警报关闭时,javascript仍然认为您按住了鼠标按钮,因此该项会粘在鼠标上

只需删除警报并执行<代码>控制台.log('Huffer-MouSeDelf()调用'');< /COD>而不是

您不应在脚本中间警告,这就是脚本中发生的事情:

  • 鼠标按下-项目可拖动
  • 警报-javascript暂停
  • 释放鼠标单击ok,但javascript不知道这一点,因为脚本已暂停
  • 当警报关闭时,javascript仍然认为您按住了鼠标按钮,因此该项会粘在鼠标上

只需删除警报并执行
console.log('Handler for.mousedown()called')
相反

您在鼠标按下按钮中的警报会弄乱脚本。您不需要查找鼠标按下按钮,但无论如何,您已经在可排序初始值设定项上附加了一个停止回调函数。只需通过查找
ui.item
将代码添加到其中,因为这是当前拖动的项


我在这里设置了一个提琴:

你在mousedown中的警报正在弄乱脚本。你不需要寻找mousedown,但无论如何,你已经有一个stop回调函数附加到你的可排序初始值设定项。只要通过查找
ui.item
将你的代码添加到其中,因为它是当前拖动的项


我在这里设置了一个提琴:

这个项目仍然粘在鼠标上
这是什么意思?你能做一个JSFIDLE吗?你确定你没有在这里谈论拖放吗?我在上面添加了整个代码。我无法让它在JSFIDLE上工作,不确定如何使用它…@david,这是jquery UI可排序的手风琴
这个项目是直到粘上鼠标为止
这是什么意思?你能做一个JSFIDLE吗?你确定你不是在这里谈论拖放吗?我在上面添加了全部代码。我无法让它在JSFIDLE上工作,不知道如何使用它…@david,这是jquery UI可排序的手风琴哦,是的,我忘了它需要是鼠标,是的,我忘了它需要是鼠标修普