在我们的公司待办事项列表中使用jQuery Tablesorter和jQuery Tablesorter Filter plugin,它在大多数情况下都能很好地运行。我遇到的一个问题是“重置搜索”按钮。
“重置搜索”按钮会重置结果以删除所有搜索过滤器,但选择菜单的占位符不会重置为默认值。这是一系列事件:
-Default占位符:'选择一个值' - 在选择菜单中选择一个选项,例如“值#1” - 使用“重置搜索”按钮重置过滤结果,结果重置,但占位符仍为“值#1”
我缺少什么来纠正这个?单击“重置搜索”按钮时,plugin's演示会重置选择菜单的占位符。
jQuery
$( '#todo-list' ).tablesorter( {
widgets: ["filter"],
widgetOptions : {filter_reset : '.reset'}
$this->list .= '<thead><tr>';
$this->list .= '<th id="checkbox-col" class="sorter-false filter-false"></th>';
$this->list .= '<th id="item-col" data-placeholder="Enter search term">'.apply_filters( 'ctdl_heading_item', esc_html__( 'Item', 'cleverness-to-do-list' ) ).'</th>';
/** @var $priority int */
if ( $priority == 1 ) $this->list .= '<th id="priority-col">'.apply_filters( 'ctdl_heading_priority', esc_html__( 'Priority', 'cleverness-to-do-list' ) ).'</th>';
/** @var $progress int */
if ( $progress == 1 && CTDL_Loader::$settings['show_progress'] == 1 ) $this->list .= '<th id="progress-col">'.apply_filters( 'ctdl_heading_progress', esc_html__( 'Progress', 'cleverness-to-do-list' ) ).'</th>';
/** @var $categories int */
if ( $categories == 1 && CTDL_Loader::$settings['categories'] == 1 ) $this->list .= '<th id="category-col" class="filter-select" data-placeholder="Filter">'.apply_filters(
'ctdl_heading_category', esc_html__( 'Expeditor',
'cleverness-to-do-list' ) ).'</th>';
if ( CTDL_PP ) $this->list .= '<th id="planner-col">'.apply_filters( 'ctdl_heading_planner', esc_html__( 'Post Planner', 'cleverness-to-do-list' ) ).'</th>';
/** @var $assigned int */
if ( $assigned == 1 && ( CTDL_Loader::$settings['assign'] == 0 && ( CTDL_Loader::$settings['list_view'] != 0 && CTDL_Loader::$settings['show_only_assigned'] == 0
&& ( current_user_can( CTDL_Loader::$settings['view_all_assigned_capability'] ) ) ) || ( CTDL_Loader::$settings['list_view'] != 0 && CTDL_Loader::$settings['show_only_assigned'] == 1 )
&& CTDL_Loader::$settings['assign'] == 0 ) ) $this->list .= '<th id="assigned-col" class="filter-select" data-placeholder="Filter">'.apply_filters( 'ctdl_heading_assigned',
esc_html__( 'Assigned to', 'cleverness-to-do-list' ) ).'</th>';
为表格生成HTML:
<tr class="tablesorter-filter-row">
<!--The below <td> correctly resets to the placeholder "Enter search term" when the reset button is clicked-->
<td>
<input class="tablesorter-filter" type="search" placeholder="Enter search term" data-column="1" style="width: 98%;"></input>
</td>
<!--The below <td> does not reset to the placeholder "Filter" when the reset button is clicked-->
<td>
<div id="msdrpdd20_msddHolder" class="ddOutOfVision" style="height: 0px; overflow: hidden; position: absolute;">
<select id="msdrpdd20" class="tablesorter-filter" data-column="2" tabindex="-1">
<option value="">
Filter
</option>
<option value="Carlos">
Carlos
</option>
</select>
</div>
<div id="msdrpdd20_msdd" class="dd ddcommon borderRadius" style="width: 56px;" tabindex="0"> … </div>
</td>
</tr>