我在第二次发布这个问题。我仍然没有得到任何答案。它像四天一样,我一直陷入这个问题。 draggable()在动态创建的表格中不起作用我已经比较了手动创建的表格和动态表格的DOM,每个事物都是相同的,但它在手动创建的表格中而不是在动态表格中工作。这意味着在手动我可以移动表列像重新排序而不是动态。请在这里需要帮助。下面是我的代码。Draggable()在jquery中不工作
function addTab() {
var tab_title = $tab_title_input.val() || 'Tab '+tab_counter;
//alert(tab_title);
$tabs.tabs('add', '#tabs-'+tab_counter, tab_title);
var newTableDiv = $("<div />",{id: 'dialog'+tab_counter});
newTableDiv.appendTo("body");
alert("div appended to body"+" "+'dialog'+tab_counter);
var setCSS = {
'width' : '100%',
'cellspacing' : '1px',
'cellpadding' : '2px'
}
var newTable = $('<table class="ui-widget" width="100%" border="0" cellspacing="1" cellpadding="2">'+
'<thead id="myTableHead'+tab_counter+'" class="ui-widget-header" style="display: table-header-group;">'+
'<tr><th><strong>Symbol</strong></th>'+
'<th><strong>Price</strong></th>'+
'<th><strong>Volume</strong></th>'+
'<th><strong>Buy</strong></th>'+
'<th><strong>Sell</strong></th></tr></thead>'+
'<tbody id="sortable'+tab_counter+'" class="ui-widget-content" style="display: table-row-group;">'+
'<tr><td>PSO</td><td>100.00</td><td>12</td><td>120.00</td><td>130.00</td></tr>'+
'<tr><td>ASO</td><td>200.00</td><td>11</td><td>120.00</td><td>130.00</td></tr></tbody></table>').attr('id', 'myTable'+tab_counter);
$(newTableDiv).append(newTable);
$('#myTable'+tab_counter).tablesorter();
$('#myTable'+tab_counter).draggable(); //**not working**
$('#sortable'+tab_counter).sortable();
if ($("#myTable"+tab_counter).length > 0) {
alert("id exists");
}
alert("#myTable"+tab_counter);
var myDiv = $("<div />", { "class":"ui-tabs-panel ui-widget-content ui-corner-bottom",id: 'tabs-'+tab_counter});
myDiv.append("#tabs");
$("#sortable"+tab_counter).show();
$("#myTableHead"+tab_counter).show();
$('#dialog'+tab_counter).prependTo('#tabs-'+tab_counter);
tab_counter++;
//alert(tab_counter);
}
我需要帮助。
@Java_Newbie它完全打破了吗?你是什么意思动态创建表?由什么动态创建?表格之间的标记有没有区别(手动/动态)?这两种类型(插件或其他)之间是否存在环境差异? – JohnP 2011-05-26 07:10:55
@JohnP .....它不会完全打破。动态的意思是我创建一个表,动态表。现在有另一个表,我手动创建,当我使用draggable()它工作正常。但是当我使用动态表时,它不会拖动表列。我也使用第三方插件http://www.danvk.org/wp/dragtable/它也可以在手动创建的表格中正常工作,但是当涉及到动态创建的表格时,它不会拖动表格列。我也用firbug检查过标记,两者都是一样的。 – 2011-05-26 07:22:29
你的表格是一个小部件,添加到一个新的选项卡,你想拖动什么?表头和列移动?这将是一件好事,如果你可以提供一个屏幕截图,这正是 – 2011-05-26 07:23:30