- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
问题是:
js 脚本通过 ajax 调用 PHP 脚本。该脚本构建了一些 html 代码,在 columntoggle
模式下产生了一个 h3 标题和一个表格 block 。结果插入到 my_content div 中,调用 table()
以 jqm 方式绘制表格。
function get_table()
{ $.ajax({
type:'post',dataType:'text',cache:false
,url:'script.php'
,data:({token:tok, sort:srt})
,success:function(data,status,request)
{ $('#my_content').html(data);
if($('#my_table').length) $('#my_table').table();
}
}
<body>
<div id="my_content"></div>
</body>
这里是 PHP 脚本构建内容的概念:
<div class="ui-corner-all custom-corners">
<div class="ui-corner-all custom-corners">
<h3>My Table</h3>
</div>
<div class="ui-body ui-body-a">
<table id="my_table" data-role="table" data-mode="columntoggle" border="0" cellpadding="4" cellspacing="1" class="ui-responsive table-stroke" data-column-btn-theme="a" data-column-btn-text="Columns" data-column-popup-theme="a">
<thead>
<tr>
<th data-priority="" colspan="1"><a href="#" onclick="re_sort('def');">Default</a></th>
<th data-priority="1" colspan="2"><a href="#" onclick="re_sort('fil');">Files</a></th>
...
</tr>
</thead>
<tbody>
<td>$type</td>
<td>$number</td>
<td>$ratio</td>
...
</tbody>
<tfooter>
<td>total</td>
<td>$sum_number</td>
<td>100%</td>
...
</tfooter>
</table>
</div>
</div>
效果很好,即使是表格顶部的列按钮也能让用户选择他想显示或不显示的列。
现在在表格标题中,有链接。他们调用一个 js re_sort 函数来更改排序标准,然后重新显示表格。
function re_sort(new_srt)
{ srt=new_srt;
get_table();
}
这也很好。
我的问题是在使用新的排序标准重新绘制表格后,列按钮不再显示/隐藏表格列。
我尝试使用以下方法清理表对象及其事件:
$('#my_table').empty(); or $('#my_content').empty();
之前
$('#my_content').html(data);
还有一些其他技巧,但我卡住了!
注意:
$('#my_table').trigger('create');
也不行。
看来我必须再调用一些东西来告诉 jqm 我要将表重新处理为一个新表。
更新:我写了一个例子来演示这个问题:http://jsfiddle.net/komet163s/2P8BG/20/
最佳答案
尝试在此处添加此 $("#my_table-popup-popup").remove();:
$('#my_content').html(code);
$("#my_table-popup-popup").remove();
if($('#my_table').length) $('#my_table').table();
我在这个答案中找到了解决方案: JQuery Mobile update table via AJAX and column-toggle stops working
关于jquery-mobile - 在 ajax 调用后,columntoggle 模式/列按钮中的 jQuery 移动表不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22868926/
首先,我要感谢 Stack Overflow 如此出色,几乎回答了我们需要的所有问题。但我再次坚持了某些事情,需要帮助。我的问题是我的 columntoggler右上角没有关闭按钮(所以,当 p:po
在这里,我在 primeFaces 中为我的表使用 dataExporter,它在 type="xls"中成功导出,但问题是,此外我还使用 columnToggler 来选择列,我只想定位那些要导出的
在这里,我在 primeFaces 中为我的表使用 dataExporter,它在 type="xls"中成功导出,但问题是,此外我还使用 columnToggler 来选择列,我只想定位那些要导出的
我在获取 Column 组件对象时遇到问题。 这里是应该实现的逻辑: 用户使用 primefaces columnToggler 切换表格列(当用户点击复选框时,调用 ajax 监听器方法) 在监听器
我正在使用 PrimeFaces v.5 此版本发布了一个新组件 ColumnToggler , 当 View 被渲染时,刷新所有复选框被选中作为默认操作。 我需要做的是; 在初始化 View 时取消
问题是: js 脚本通过 ajax 调用 PHP 脚本。该脚本构建了一些 html 代码,在 columntoggle 模式下产生了一个 h3 标题和一个表格 block 。结果插入到 my_cont
我是一名优秀的程序员,十分优秀!