请大家帮忙,如何实现对动态增加的tr实现拖拽?
时间:2009-08-14
来源:互联网
我对下面的这个table,进行动态的增加tr,然后使用jquery.tablednd_0_5.js,将该table定义为可拖拽的的table
<TABLE id="item_list" class="fb_add" width="100%">
<TR>
<TH class="fb_add_title">控件ID</TH>
<TH class="fb_add_title">控件名称</TH>
<TH class="fb_add_title">控件类型</TH>
<TH class="fb_add_title">控件说明</TH>
</TR>
<TR>
<TD class="menu">测试</TD>
<TD class="menu">测试</TD>
<TD class="menu">测试</TD>
<TD class="menu">测试</TD>
</TR>
</TABLE>
$('#item_list').tableDnD();
但是我只能对默认存在的这一行进行拖拽,对于动态增加的tr,无法实现拖拽,请大家帮忙,如何实现对动态增加的tr实现拖拽?
<TABLE id="item_list" class="fb_add" width="100%">
<TR>
<TH class="fb_add_title">控件ID</TH>
<TH class="fb_add_title">控件名称</TH>
<TH class="fb_add_title">控件类型</TH>
<TH class="fb_add_title">控件说明</TH>
</TR>
<TR>
<TD class="menu">测试</TD>
<TD class="menu">测试</TD>
<TD class="menu">测试</TD>
<TD class="menu">测试</TD>
</TR>
</TABLE>
$('#item_list').tableDnD();
但是我只能对默认存在的这一行进行拖拽,对于动态增加的tr,无法实现拖拽,请大家帮忙,如何实现对动态增加的tr实现拖拽?
[ 此帖被winer_mokou在2009-08-22 15:53重新编辑 ]
作者: winer_mokou 发布时间: 2009-08-14
增加以后再次调用draggable()
事件绑定只对当前元素有效
事件绑定只对当前元素有效
作者: keakon 发布时间: 2009-08-14
jQuery 1.3中新增的方法。给所有当前以及将来会匹配的元素绑定一个事件处理函数(比如click事件)。也能绑定自定义事件。
目前支持 click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, keydown, keypress, keyup。
还不支持 blur, focus, mouseenter, mouseleave, change, submit
与bind()不同的是,live()一次只能绑定一个事件。
这个方法跟传统的bind很像,区别在于用live来绑定事件会给所有当前以及将来在页面上的元素绑定事件(使用委派的方式)。比如说,如果你给页面上所有的li用live绑定了click事件。那么当在以后增加一个li到这个页面时,对于这个新增加的li,其click事件依然可用。而无需重新给这种新增加的元素绑定事件。
.live()与流行的liveQuery插件很像,但有以下几个主要区别:
.live 目前只支持所有事件的子集,支持列表参考上面的说明。
.live 不支持liveQuery提供的“无事件”样式的回调函数。.live只能绑定事件处理函数。
.live 没有"setup"和"cleanup"的过程。因为所有的事件是委派而不是直接绑定在元素上的。
要移除用live绑定的事件,请用die方法
--------------------------------------------------------------------------------
Added in jQuery 1.3: Binds a handler to an event (like click) for all current - and future - matched element. Can also bind custom events.
Possible event values: click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, keydown, keypress, keyup Currently not supported: blur, focus, mouseenter, mouseleave, change, submit This method works and behaves very similarly to jQuery's bind method but with one important distinction: When you bind a "live" event it will bind to all current and future elements on the page (using event delegation). For example if you bound a live click to all "li" elements on the page then added another li at a later time - that click event would continue to work for the new element (this is not the case with bind which must be re-bound on all new elements). .live() behaves similarly to the popular liveQuery plugin but with a few major differences: .live (currently) supports a subset of all events. Note the full list of supported/not-supported events above. .live doesn't support the no-event style callback that liveQuery provides. Only event handlers can be bound with .live. .live doesn't have a "setup" or "cleanup" step, since all events are delegated rather than bound directly to an element. To remove a live event you should use the die method.
返回值
jQuery
参数
type (String) : 一个或多个用空格分隔的事件名
fn (Function) : 欲绑定的事件处理函数
示例
点击生成的p依然据有同样的功能。
HTML 代码:
<p>Click me!</p>
jQuery 代码:
$("p").live("click", function(){
$(this).after("<p>Another paragraph!</p>");
});
目前支持 click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, keydown, keypress, keyup。
还不支持 blur, focus, mouseenter, mouseleave, change, submit
与bind()不同的是,live()一次只能绑定一个事件。
这个方法跟传统的bind很像,区别在于用live来绑定事件会给所有当前以及将来在页面上的元素绑定事件(使用委派的方式)。比如说,如果你给页面上所有的li用live绑定了click事件。那么当在以后增加一个li到这个页面时,对于这个新增加的li,其click事件依然可用。而无需重新给这种新增加的元素绑定事件。
.live()与流行的liveQuery插件很像,但有以下几个主要区别:
.live 目前只支持所有事件的子集,支持列表参考上面的说明。
.live 不支持liveQuery提供的“无事件”样式的回调函数。.live只能绑定事件处理函数。
.live 没有"setup"和"cleanup"的过程。因为所有的事件是委派而不是直接绑定在元素上的。
要移除用live绑定的事件,请用die方法
--------------------------------------------------------------------------------
Added in jQuery 1.3: Binds a handler to an event (like click) for all current - and future - matched element. Can also bind custom events.
Possible event values: click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, keydown, keypress, keyup Currently not supported: blur, focus, mouseenter, mouseleave, change, submit This method works and behaves very similarly to jQuery's bind method but with one important distinction: When you bind a "live" event it will bind to all current and future elements on the page (using event delegation). For example if you bound a live click to all "li" elements on the page then added another li at a later time - that click event would continue to work for the new element (this is not the case with bind which must be re-bound on all new elements). .live() behaves similarly to the popular liveQuery plugin but with a few major differences: .live (currently) supports a subset of all events. Note the full list of supported/not-supported events above. .live doesn't support the no-event style callback that liveQuery provides. Only event handlers can be bound with .live. .live doesn't have a "setup" or "cleanup" step, since all events are delegated rather than bound directly to an element. To remove a live event you should use the die method.
返回值
jQuery
参数
type (String) : 一个或多个用空格分隔的事件名
fn (Function) : 欲绑定的事件处理函数
示例
点击生成的p依然据有同样的功能。
HTML 代码:
<p>Click me!</p>
jQuery 代码:
$("p").live("click", function(){
$(this).after("<p>Another paragraph!</p>");
});
作者: winer_mokou 发布时间: 2009-08-22
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28