2013-10-08 23 views
0

我在搜索字段中遇到此問題。當我點擊輸入按鈕時,搜索會被觸發,但只能在Chrome中正常使用。如果我在IE中點擊輸入按鈕,頁面中唯一的變化,如果我點擊按鈕,第二次搜索......的作品。搜索在IE中不起作用。只適用於Chrome

$(document).ready(function(event) { 
     $("#searchField").keypress(function(event) { 
      if (event.which == 13) { 
       search_value = $('#searchField').val(); 
       proj_id = $('#projectId').val(); 
       //alert (search_value + '-' + proj_id); 
       searchMeeting(search_value, proj_id); 
      } 

     }); 
    }); 

function searchMeeting(search_value, proj_id) { 

    var lastSearchValue = $('#searchField').val(); 
    if (proj_id != "") { 
     $.ajaxSettings.traditional = true; 
     $.ajax({ 
      url : '../meeting/searchMeeting.action', 
      type : 'post', // method 
      dataType : 'html', 
      data : { // data to send 
       "searchValue" : search_value, 
       "projectId" : proj_id 
      }, 
      error : function() { // fail 
       alert('Failed to search!'); 
      }, 
      success : function(html) {// success 
       $('#backToList').attr("style","display: none;"); 
       $("#meeting_content").html(html); 
       $("#searchField").val(lastSearchValue); 
       bindTableEvents(); 
      } 
     }); 
    } 
} 
+0

您是否使用輸入類型「搜索」? –

+0

哪個IE?他們不都支持搜索很好 – Martijn

+1

此外,是否觸發了ajaxcall? – Martijn

回答

1

不是檢查的鍵碼的,你可以把它放在一個提交形式:

<form method="post"> 
    <input type="search" id="searchField" /> 
</form> 

$("#searchField").closest('form').on('submit',function(event) { 
    event.preventDefault(); 
    search_value = $('#searchField').val(); 
    proj_id = $('#projectId').val(); 
    //alert (search_value + '-' + proj_id); 
    searchMeeting(search_value, proj_id); 
}); 

Offcourse你可以添加一個ID的形式和綁定事件到

+0

我相信在函數searchMeeting中的問題。 –

相關問題