{"id":14584259,"date":"2021-06-22T15:13:55","date_gmt":"2021-06-22T15:13:55","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/search-function-bugs\/"},"modified":"2021-06-22T15:13:55","modified_gmt":"2021-06-22T15:13:55","slug":"search-function-bugs","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/search-function-bugs\/","title":{"rendered":"Search function bugs"},"content":{"rendered":"<p>First of all: interesting plug-in and very useful for many people, I think. It should have much more attention (and downloads).<\/p>\n<p>Anyway, I&#8217;m testing the search function and have a few comments, which may be some improvements. I&#8217;ve made some modifications to the wibergsweb.js file, but let me make clear that I&#8217;m not an expert in javascript.<\/p>\n<p>The thing is that if you click on &#8216;Reset&#8217; the full table displays, although I&#8217;ve set hidetable_load to &#8220;yes&#8221;. Therefor, I&#8217;ve added one line after line 35, so they now look like this:<\/p>\n<pre><code>\ntablewrapper_obj[0].outerHTML = response.tabledata;\n$(&#039;tr&#039;).hide();\n<\/code><\/pre>\n<p>If you now click on &#8216;Reset&#8217; the table disappears. Maybe it&#8217;s even enough to just comment that line with &#8216;tablewrapper_obj&#8217;, possibly with an &#8216;if&#8217; statement that checks whether you want a clean page on pageload?<\/p>\n<p>Another thing is that a click on &#8216;Search&#8217; with nothing filled in the searchbox also displays the full table. Not ideal. To check whether there&#8217;s a value in the search box (and what the length is), I&#8217;ve included an &#8216;if&#8217; statement after line 65. It looks like this:<\/p>\n<pre><code>\n        var search_text = $(this).parent().find(&#039;.search-text&#039;).val(); \n\t\tif (search_text.length &lt; 5) {  \n\t\t\talert(&#039;Please enter a minimumn of 5 characters&#039;);\n\t\t\treturn false;\n\t\t}\n        var h = $(this).data();\n<\/code><\/pre>\n<p>This checks if the search string is at least 5 characters, otherwise it will display an alert and abort the function. Can be any length of course. I suppose it could be further adjusted by checking for numbers only or letters only.<\/p>\n<p>And lastly, there&#8217;s a thing I couldn&#8217;t find a solution for. If you search for anything that you are sure is not in the table, the &#8216;result&#8217; is again the full table display. That&#8217;s of course not how search should be working. There should be a &#8220;Sorry, didn&#8217;t find anything&#8221; message. But apart from that I&#8217;m wondering why there even is a &#8216;result&#8217;, it should return nothing. Has this to do with what seems to be a &#8216;wildcard&#8217; function in search?<\/p>\n<p>Again, a very good plug-in and I hope you keep up the good work!<\/p>\n","protected":false},"template":"","class_list":["post-14584259","topic","type-topic","status-publish","hentry","topic-tag-csv","topic-tag-tables"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/14584259","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/14584259\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=14584259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}