【发布时间】:2021-02-20 12:05:41
【问题描述】:
我有一个用于我的网站的房地产插件。此插件的搜索工具无法使用键盘上的回车键。我想在搜索工具中输入关键字后使用回车键进行搜索。我该怎么做?
我认为相关的代码是这样的:
$('.ere-advanced-search-btn', css_class_wrap).on('click', function (e) {
e.preventDefault();
var search_form = $(this).closest('.search-properties-form'),
search_url = search_form.data('href'),
search_field = [],
query_string = '?';
if (search_url.indexOf('?') !== -1) {
query_string = '&';
}
$('.search-field', search_form).each(function () {
var $this = $(this),
field_name = $this.attr('name'),
current_value = $this.val(),
default_value = $this.data('default-value');
if (current_value != default_value) {
search_field[field_name] = current_value;
}
});
$('.ere-sliderbar-filter', search_form).each(function () {
var $this = $(this),
field_name_min = $this.find('.min-input-request').attr('name'),
field_name_max = $this.find('.max-input-request').attr('name'),
current_value_min = $this.find('.min-input-request').val(),
current_value_max = $this.find('.max-input-request').val(),
default_value_min = $this.data('min-default'),
default_value_max = $this.data('max-default');
if (current_value_min != default_value_min || current_value_max != default_value_max) {
search_field[field_name_min] = current_value_min;
search_field[field_name_max] = current_value_max;
}
});
var other_features = '';
$('[name="other_features"]', search_form).each(function () {
var $this = $(this),
value = $this.attr('value');
if ($this.is(':checked')) {
other_features += value + ";";
}
});
if (other_features !== '') {
other_features = other_features.substring('0', other_features.length - 1);
search_field['other_features'] = other_features;
}
if (search_field !== []) {
for (var k in search_field) {
if (search_field.hasOwnProperty(k)) {
query_string += k + "=" + search_field[k] + "&";
}
}
}
query_string = query_string.substring('0', query_string.length - 1);
window.location.href = search_url + query_string;
});
【问题讨论】:
-
我对输入键没有问题(在 chrome 上)
-
另外搜索工具不在
-
如果我们没有显示问题的样本,将很难为您提供更多帮助...