.draggable 的 Jquery .trigger('stop') 方法 [英] Jquery .trigger('stop') method for .draggable

查看:26
本文介绍了.draggable 的 Jquery .trigger('stop') 方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$('#element').draggable ({
    stop: function () {
        alert ('stopped');
        //do some action here
    }
}).trigger('stop');

什么都没有发生,认为 #element 现在是可拖动的,并且事件在拖动完成后会执行.我试过 .triggerHandle 以及 'dragstop' 作为事件类型,没有运气

nothing happens, thought #element is draggable now and event does execute after drag is complete. I tried .triggerHandle as well as 'dragstop' as eventtype, no luck

推荐答案

改用这个来触发它:

.trigger('dragstop')

如果您希望它完全像正常事件一样运行,也可以使用 .bind('dragstop', function) 来附加它,启动选项的行为会略有不同.

If you want it to behave completely as a normal event, use .bind('dragstop', function) to attach it as well, the start option behaves slightly differently.

这篇关于.draggable 的 Jquery .trigger('stop') 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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