搜索不在设备中工作

时间:2017-05-22 09:19:13

标签: javascript jquery

我有一个搜索框,当用户输入任何文字并按回车或点击搜索图标时,它应该重定向到搜索页面。

功能在桌面上运行良好,但仅在Android设备中它无法正常工作,如果我按回车键或点击搜索图标没有任何反应。

我尝试过添加焦点,kepyess,touchstart,但没有任何帮助。请帮忙

更新

我发现有两个搜索模型用于桌面,另一个用于移动。

在移动设备中搜索时,输入文本值为空,因为它占用了桌面搜索的值。

我已经更新了脚本,但仍然没有获取移动输入值。请让我知道我做错了什么

$(".newsroom_search-box,.newsroom_search-box_mobile").submit(setupNewsroomSearch);

$('.search_banner-q_newsroom,.search_banner-q_newsroom_mobile').click(function() {
  $('.search_banner-q_newsroom,.search_banner-q_newsroom_mobile').focus();
});


$(".search_desktop-newsroom-submit,.search_desktop-newsroom-submit_mobile").click(setupNewsroomSearch);


function setupNewsroomSearch(e) {
  e.preventDefault();

  if ($(".search_banner-q_newsroom,.search_banner-q_newsroom_mobile").val().trim().length === 0) {
    return false;
  } else {
    alert('called');
    var tracking = '&ei=newsroom_search';
    redirectToSearchPage($(".search_banner-q_newsroom").val(), "newsroom", "commbank_all", tracking);
  }

}
Desktop Mockup
<div class="newsroom-search-wrapper">
  <form class="newsroom_search-box">
    <div class="search-box">
      <input type="text" class="search_banner-q_newsroom" aria-label="Search" name="query" placeholder="${newsRoomBrowseContainerModel.searchText}" />
      <i class="icon-search search_desktop-newsroom-submit" aria-hidden="true"></i>
    </div>
  </form>
</div>
Search Mockup
<div class="newsroom-search-wrapper_mobile mobile-search">
  <form class="newsroom_search-box_mobile">
    <div class="search-box">
      <input type="text" class="search_banner-q_newsroom_mobile" aria-label="Search" name="query" placeholder="${newsRoomBrowseContainerModel.searchText}" />
      <i class="icon-search search_desktop-newsroom-submit_mobile" aria-hidden="true"></i>
    </div>
  </form>
</div>

0 个答案:

没有答案