开发者

Safari Search Field Cancel Button Callback?

开发者 https://www.devze.com 2023-03-02 10:48 出处:网络
I have a table with some fields and I do a \"live search\" to find the rows… My code开发者_Python百科 for this is this:

I have a table with some fields and I do a "live search" to find the rows…

My code开发者_Python百科 for this is this:

 $("#searchforpage").keyup(function(pd) {
      pd.preventDefault();
      $("table tbody tr").hide();
  $("table tbody").find("tr:contains('"+$("#searchforpage").val().toLowerCase()+"')").show();
 });

This works and is not the real problem, but my input field is a type="search" so that safari has the magnifying glass and the search history and the x in the right corner.

And the x is the problem if clicked nothing happens because the hole code responds to keyup.

so i would want to do something like that to show all rows again:

$("#searchforpage::-webkit-search-cancel-button").click(function() {
  $("table tbody tr").show();
});

How do I get a callback form the cancel button to show all rows?


ok my workaround for this is now that i now use every click in the search field… my thought is that if you click in the field again you probably want to search for something completely different:

$("#searchforpage").click(function() {
   $(this).val("");
   $("table tbody tr").show();
});

But if someone has a correct solution for this i would like to know it.

0

精彩评论

暂无评论...
验证码 换一张
取 消