jQuery的ui.draggable不调用自定义函数 [英] jQuery ui.draggable does not Call custom Function

查看:347
本文介绍了jQuery的ui.draggable不调用自定义函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JavaScript函数showAlert()。有一个可拖动图像。之后拖拽停止时,我们需要显示该警报。它不工作我们如何纠正?

 < HTML的xmlns =htt​​p://www.w3.org/1999/xhtml>

<头=服务器>

    <冠军>< /标题>
    <脚本类型=文/ JavaScript的SRC =htt​​p://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js>< / SCRIPT>
    <脚本SRC =脚本/ ui.core.js类型=文/ JavaScript的>< / SCRIPT>
    <脚本SRC =脚本/ ui.draggable.min.js类型=文/ JavaScript的>< / SCRIPT>

    <脚本类型=文/ JavaScript的>

        $(函数()
        {

            $(#D1)。拖动(
            {

                阻力:功能(事件,UI)
                {
                },

                停止:功能(事件,UI)
                {
                    showAlert();
                },

                光标:搬家

            });

        });

        功能showAlert()
        {
            警报(辞海);
        }



    < / SCRIPT>

< /头>
<身体GT;
    <表格ID =Form1的=服务器>
    < D​​IV的风格=边界:2px的实心橙色;宽度:500px的;高度:300像素; >
    < BR />
        < IMG SRC =MyIMages / RedSquare.jpgALT =ID =D1=服务器/>
    < BR />
    < / DIV>
    < /形式GT;
< /身体GT;
< / HTML>
 

解决方案

我试着用了jQuery UI库,它的工作 HTTP ://jsfiddle.net/5HyyP/

I have a javascript function showAlert(). There is a draggable image. After the drag is stopped, we need to show the alert. Its not working How do we correct it?

    <html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title></title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    <script src="Scripts/ui.core.js" type="text/javascript"></script>
    <script src="Scripts/ui.draggable.min.js" type="text/javascript"></script>

    <script type="text/javascript">

        $(function () 
        {

            $("#d1").draggable(
            {

                drag: function (event, ui) 
                {
                },

                stop: function (event, ui) 
                {
                    showAlert();
                },

                cursor: "move"

            });

        });

        function showAlert() 
        {
            alert("hai");
        }



    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div style="border:2px solid orange; width:500px; height:300px;"  >
    <br />
        <img src="MyIMages/RedSquare.jpg" alt="" id="d1" runat="server" />
    <br />
    </div>
    </form>
</body>
</html>

解决方案

I tried with the jquery UI libraries and it worked http://jsfiddle.net/5HyyP/

这篇关于jQuery的ui.draggable不调用自定义函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆