我在使用表单中的datepicker重新加载特殊字段时遇到问题。
该网站在http://eskelak.eus/上线,当我尝试在搜索表单中执行搜索时,第一次没问题,但是当我按下重置按钮之前,datepicker字段没有恢复。
function the_search_form() {
global $wpdb;
$firstname = filter_input(INPUT_GET, 'first_name', FILTER_SANITIZE_STRING);
$lastname = filter_input(INPUT_GET, 'last_name', FILTER_SANITIZE_STRING);
$province = filter_input(INPUT_GET, 'province', FILTER_SANITIZE_STRING);
$locality = filter_input(INPUT_GET, 'locality', FILTER_SANITIZE_STRING);
$from = filter_input(INPUT_GET, 'from', FILTER_SANITIZE_STRING);
$to = filter_input(INPUT_GET, 'to', FILTER_SANITIZE_STRING);
if (!empty($locality) && isset($locality)) {
$locality_row = $wpdb->get_row( $wpdb->prepare(
'SELECT * FROM wp_eskelak_locality WHERE id = %s',
$locality
) );
$province = $locality_row->province;
}
$active = ' class="active"';
?>
<!-- START SEARCH FORM -->
<form method="get" action="/index.php" id="search">
<?php $lang = get_language_for_link() ?>
<?php if ($lang == '') : ?>
<input type="hidden" name="page_id" value="370"/>
<?php else : ?>
<input type="hidden" name="page_id" value="372"/>
<?php endif ?>
<h3><?php _e('Buscar Eskelas', 'eskelak')?></h3>
<div class="form-group">
<input type="text" name="first_name" value="<?php echo $firstname ?>"
placeholder="<?php _e( 'Introducir nombre', 'eskelak') ?>">
<input type="hidden" name="province" value="<?php echo isset($province) ? $province : '' ?>"/>
<button data-filter="true" value="alava"<?php echo $province=='alava'? $active : '' ?>><?php _e('Araba-Álava') ?></button>
<button data-filter="true" value="guipuzcoa"<?php echo $province=='guipuzcoa'? $active : '' ?>><?php _e('Gipuzkoa') ?></button>
<button data-filter="true" value="vizcaya"<?php echo $province=='vizcaya'? $active : '' ?>><?php _e('Bizkaia') ?></button>
</div>
<div class="form-group">
<input type="text" name="last_name" value="<?php echo $lastname ?>"
placeholder="<?php _e( "Introducir apellidos", 'eskelak' ) ?>">
<?php the_localities() ?><input id="desde" type="text" name="from" data-placeholder="<?php _e('Desde', 'eskelak') ?>" class="datepicker" value="<?php echo $from ?>"
placeholder="<?php _e('Desde', 'eskelak') ?>"/>
<input id="hasta" type="text" name="to" data-placeholder="<?php _e('Hasta', 'eskelak') ?>" class="datepicker" value="<?php echo $to ?>"
placeholder="<?php _e('Hasta', 'eskelak') ?>"/>
</div>
<div class="form-group">
<button data-send="enviar" type="submit" style="margin: 3px 8px;float: right;" class="buscar">
<img src="<?php echo get_template_directory_uri()?>/images/icons/search.png" alt="<?php _e('Buscar')?>" />
<?php _e('Buscar', 'eskelak')?>
</button>
<button form="search" data-reset="reset" id="reset_filter" type="submit" style="margin: 3px 8px;float: right;" >
<!-- <img src="<?php // echo get_template_directory_uri()?>/images/icons/search.png" alt="<?php // _e('Buscar')?>" /> -->
<?php _e('Reiniciar Filtro', 'eskelak')?>
</button>
</div>
</form>
<div class="clear"></div>
<!-- END SEARCH FORM -->
<?php}
答案 0 :(得分:1)
这是因为设置script
datepicker
<script src="data:text/javascript,(function(%24)%7B%24(%22.datepicker%22).datepicker(%7BshowButtonPanel%3Atrue%2CdateFormat%3A%22dd%2Fmm%2Fyy%22%7D)%3B%7D)(jQuery)%3B" type="text/javascript">(function($){$(".datepicker").datepicker({showButtonPanel:true,dateFormat:"dd/mm/yy"});})(jQuery);</script>
在主页中位于表单之后的在第二页中缺失。
答案 1 :(得分:0)
看起来您的网站需要更新。在Chrome DevTools日志中,我有:
JQMIGRATE: Logging is active
jquery-migrate-1.1.1.js:40 JQMIGRATE: jQuery.browser is deprecated
jquery-migrate-1.1.1.js:42 console.trace()migrateWarn @ jquery-migrate-1.1.1.js:42
jquery-migrate-1.1.1.js:40 JQMIGRATE: 'hover' pseudo-event is deprecated, use 'mouseenter mouseleave'
jquery-migrate-1.1.1.js:42 console.trace()migrateWarn @ jquery-migrate-1.1.1.js:42
作为第一步,你应该摆脱那些警告。
希望会有所帮助!