一直在我们公司的 To-Do List 上使用 jQuery Tablesorter 和 jQuery Tablesorter Filter插件,它在大多数情况下都非常好用。我遇到的一个问题是“重置搜索”按钮。
“重置搜索”按钮会重置结果以删除所有搜索过滤器,但选择菜单的占位符不会重置为其默认值。这是事件的顺序:
- 默认占位符:“选择一个值” - 在选择菜单中选择一个选项,例如“值 #1” - 使用“重置搜索”按钮重置过滤结果,结果被重置,但占位符仍然是“值 #1”
我缺少什么来纠正这个问题吗?当单击“重置搜索”按钮时,该插件的演示会重置选择菜单的占位符。
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>