我在JQuery對話框中使用Tablesorter過濾器。當我第一次打開對話框時,Tablesorter過濾器加載並正常工作。該對話框包含一個下拉列表,當我從此下拉列表中選擇值時,對話框將重新加載並顯示數據,但是Tablesorter過濾器不會顯示/可見。Tablesorter過濾器沒有在JQuery對話框中顯示更改事件
任何人都可以幫我解決這個問題。
感謝
var $dialogproperties = $('#dialogs');
$(document).on('change', '#ddl_Com', function (e) {
e.preventDefault();
var url = getURL;
var data1 = getValues();
url = '@Url.Action("Com_submit")?ID=' + id;
$.post(url, data1, function (data) {
//// Open popup dialog box
var tmp = data.commentdisplay.replace(/\n/g, '<br />');
$dialogproperties.html('');
$dialogproperties.dialog({ title: $('#title').text() });
$dialogproperties.html(tmp);
$dialogproperties.dialog('open');
});
return false;
});
$(function() {
//// - Dialog box width and height
var wWidth = $(window).width();
var dWidth = wWidth * 0.9;
var wHeight = $(window).height();
var dHeight = wHeight * 0.9;
var dialog = "";
dialog = $("#dialogs").dialog({
autoOpen: false,
modal: true,
width: dWidth,
height: dHeight,
fluid: true,
open: function (event, ui) {
stopscroll();
alert('t');
var $table = $('#tblCom');
$table.tablesorter({
textExtraction: {
'.img': function (node) {
var $node = $(node);
return $node.find('span[title]').attr('title');
}
},
imgAttr: 'title',
ignoreCase: false,
widthFixed: true,
widgets: ["filter", "columnSelector"],
widgetOptions: {
filter_useParsedData: true,
filter_columnFilters: true,
filter_ignoreCase: true,
filter_defaultAttrib: 'data-value',
columnSelector_mediaquery: false
}
});
},
close: function (event, ui) {
}
});
});
請分享您所使用的代碼之前,請確保HTML已經對話框內呈現。 – Mottie
@Mottie,我添加了上面的代碼 –
我不得不更新答案,但我認爲[它是相關的](https://stackoverflow.com/a/30358176/145346) - [demo](http:// jsfiddle.net/Mottie/fg85fzqj/)。本質上,第二次打開對話框時,tablesorter已經被初始化,所以更新內容或跳過初始化。 – Mottie