jquery ui error for ui.draggable("destroy")
jquery ui error for ui.draggable("destroy")
当我把<div>
放在容器上时,我想删除它的拖动属性。但是对于下面的代码,我得到了一个错误"Property 'draggable' of object #<Object> is not a function"
。
$( "#fighter1" ).draggable(); //fighter1 is the id of draggable object
$( "#fighter2" ).draggable();
$( "#fighter3" ).draggable();
$( "#fighter4" ).draggable();
$( "#fighter5" ).draggable();
$( "#fighter6" ).draggable();
$( "#dest" ).droppable({ //dest is the id of droppable object
drop: function( event, ui ) {
ui.draggable("destroy"); //I get error here.
}
});
我使用jquery ui 1.8.12版本
我的猜测是"ui"是一个简单的旧javascript对象,而不是jQuery对象
尝试(修订):$(ui.draggable).draggable("destroy");
调用可拖动小部件方法的语法为:
$( ".selector" ).draggable( "method" );
您应该将方法名称作为string
传递给draggable()
方法。
在drop事件回调中,ui.draggable
只是对可拖动元素(语法的$( ".selector" )
部分)对应的jQuery对象的引用。
实际上,您应该调用它上的draggable()
并传递方法名:
ui.draggable.draggable("destroy");
----^------- ------^------
selector method name
--------^--------
this guy executes the method
我使用setTimeout函数解决了这个问题:
setTimeout(function(a){a.draggable("destroy");},100,ui.draggable);
相关文章:
- 有没有任何方法可以将控制器从文件加载到ui路由器$stateProvider中
- jQuery UI自动完成突然停止工作
- 如何使用skip参数使用angular ui引导进行服务器端分页
- AngularJS UI路由器不能像ng路由器那样工作
- 我可以更改剑道UI网格吗's的外键值
- 剑道UI内联编辑:如何在点击其他按钮时隐藏按钮
- Rails/JSON:如何将JSON用于jquery UI自动完成表单
- 铬:“;未捕获的语法错误:意外的标记:"
- 停止jQuery UI滑块移动超过给定值
- 可以设置“;文件名"发生错误时显示的内联脚本标记的
- JS表单提交"无法使用Chrome数据保护程序加载此页面.尝试重新加载页面.调试信息:POST CISmtuK
- 检测电话窃听,即:<a href="电话:xxx">在UIWebview上
- jQuery UI:如何保存"可排序”;
- "执行处理程序'的子请求时出错;System.Web.UI.Page'"同时使用JQu
- jquery ui的客户端缓存自动完成:javascript/jquery regex匹配字符串"索引“;对象
- 带错误的Onsen UI导航:您不能提供no"ons页”;元素到“;ons导航器”;当返回第一页时
- Metro UI CSS:如何实现class="活动的”;效应
- angular ui路由器的第一个状态具有“名称:”"`
- 需要:HTML5/Javascript UI组件做“;匹配“/"数据映射”;UI
- 使jQuery UI选择菜单"不改变”;'更改'事件