我已经使用数据表和行分组为项目添加了重置搜索按钮。 它在除IE7之外的所有浏览器中都能正常工作 在IE7中,重置搜索按钮和全部展开/全部合同按钮消失。
调试器(IE控制台)显示此错误:
SCRIPT87:参数无效
jquery.min.js,第2行,第31006行
看来调用函数ResetSearchField(); 是违规的来源。
有人能帮我解决这个问题吗? 我将衷心感谢您的帮助! 我已经设置了一个jsfiddle来说明问题: http : //jsfiddle.net/lbriquet/SG8Dm/4/
这是我正在使用的代码:
$(document).ready(function() { var oTable = $('#example').dataTable({ "oLanguage": { "sSearch": " Table search:" }, "bPaginate": false, "iDisplayLength": 100, "bLengthChange": false, "bJQueryUI": true, "sDom": 'Tlfrtip' }).rowGrouping({ bExpandableGrouping: true, bExpandSingleGroup: false, iExpandGroupOffset: -1, asExpandedGroups: [""] }); ResetSearchField(); $('.expandedOrCollapsedGroup').live('click', function() { if ($(this).hasClass('collapsed')) { $(this).addClass('expanded').removeClass('collapsed').val('Collapse All').parents('.dataTables_wrapper').find('.collapsed-group').trigger('click'); } else { $(this).addClass('collapsed').removeClass('expanded').val('Expand All').parents('.dataTables_wrapper').find('.expanded-group').trigger('click'); } }); oTable.live('filter', function() { clearTimeout(oTable.data('timeout')); var timeoutId = setTimeout(function() { if ($('label:contains(Table search: ) input').val() != '') { $('.group-item-expander.collapsed-group').trigger('click'); } else { $('.group-item-expander.expanded-group').trigger('click'); } }, 1000); oTable.data('timeout', timeoutId); }); $("#resetsearch").live('click', function(e) { oTable.fnFilter(''); GridRowCount(); }); GridRowCount(); new FixedHeader(oTable); }); function GridRowCount() { $('span.rowCount-grid').remove(); $('input.expandedOrCollapsedGroup').remove(); $('.dataTables_wrapper').find('[id|=group-id]').each(function() { var rowCount = $(this).nextUntil('[id|=group-id]').length; $(this).find('td').append($('<div />', { 'class': 'rowCount-grid' }).prepend($('<b />', { 'text': "(" + rowCount + ")" }))); }); $('.dataTables_wrapper').find('.dataTables_filter').prepend($('<input />', { 'type': 'button', 'class': 'expandedOrCollapsedGroup collapsed', 'value': 'Expand All' })); }; function ResetSearchField() { $('.dataTables_wrapper').find('.dataTables_filter').append($('<input />', { 'type': 'submit', 'class': 'ui-icon ui-icon-closethick float-right', 'id': 'resetsearch', 'border': 'none' })); };I've added a reset search button to a project using datatables and rowgrouping. It works fine in all browsers except IE7. In IE7 the reset search button AND the Expand All/Contract All button disappears.
The debugger (IE console) shows this error:
SCRIPT87: Invalid argument
jquery.min.js, line 2 character 31006
It seems that calling the function ResetSearchField(); is the offending source.
Can someone give me a hand at solving this problem? I would really appreciate your help! I've set up a jsfiddle to illustrate the problem: http://jsfiddle.net/lbriquet/SG8Dm/4/
Here is the code I'm using:
$(document).ready(function() { var oTable = $('#example').dataTable({ "oLanguage": { "sSearch": " Table search:" }, "bPaginate": false, "iDisplayLength": 100, "bLengthChange": false, "bJQueryUI": true, "sDom": 'Tlfrtip' }).rowGrouping({ bExpandableGrouping: true, bExpandSingleGroup: false, iExpandGroupOffset: -1, asExpandedGroups: [""] }); ResetSearchField(); $('.expandedOrCollapsedGroup').live('click', function() { if ($(this).hasClass('collapsed')) { $(this).addClass('expanded').removeClass('collapsed').val('Collapse All').parents('.dataTables_wrapper').find('.collapsed-group').trigger('click'); } else { $(this).addClass('collapsed').removeClass('expanded').val('Expand All').parents('.dataTables_wrapper').find('.expanded-group').trigger('click'); } }); oTable.live('filter', function() { clearTimeout(oTable.data('timeout')); var timeoutId = setTimeout(function() { if ($('label:contains(Table search: ) input').val() != '') { $('.group-item-expander.collapsed-group').trigger('click'); } else { $('.group-item-expander.expanded-group').trigger('click'); } }, 1000); oTable.data('timeout', timeoutId); }); $("#resetsearch").live('click', function(e) { oTable.fnFilter(''); GridRowCount(); }); GridRowCount(); new FixedHeader(oTable); }); function GridRowCount() { $('span.rowCount-grid').remove(); $('input.expandedOrCollapsedGroup').remove(); $('.dataTables_wrapper').find('[id|=group-id]').each(function() { var rowCount = $(this).nextUntil('[id|=group-id]').length; $(this).find('td').append($('<div />', { 'class': 'rowCount-grid' }).prepend($('<b />', { 'text': "(" + rowCount + ")" }))); }); $('.dataTables_wrapper').find('.dataTables_filter').prepend($('<input />', { 'type': 'button', 'class': 'expandedOrCollapsedGroup collapsed', 'value': 'Expand All' })); }; function ResetSearchField() { $('.dataTables_wrapper').find('.dataTables_filter').append($('<input />', { 'type': 'submit', 'class': 'ui-icon ui-icon-closethick float-right', 'id': 'resetsearch', 'border': 'none' })); };最满意答案
我找到了解决方案! 在脚本调用后,我禁用了函数ResetSearchField,如下所示:
<!--[if IE 7]> <script type="text/javascript"> function ResetSearchField() { } </script> <![endif]-->I found the solution! After the script call I disabled the function ResetSearchField like this:
<!--[if IE 7]> <script type="text/javascript"> function ResetSearchField() { } </script> <![endif]-->更多推荐
发布评论