javascript - Autocomplete search bar - <a> inside <li> not consistently clickable -


i building rails app , have post route returns suggestions (using elasticsearch that's neither here nor there). displaying , looks good, , testing noticed if make them tags in section of site, default underline on mouseover , when click them takes me desired page. however, current styling of search results (i include photo) , want understand why when click on "focused" element, doesn't understand clicking me clicking underlying (which dynamically created in javascript link built using component of json id of object.

here html:

      <li>          <form style="positive: relative; width: 700px" class="search" id = "autocomplete">           <div class="input-field">             <input autocomplete="off" name="q" id="q" type="search"  onblur="destroy();" onkeyup="myhandler();" placeholder="search..." required>             <label for="search"><i class="mdi-action-search"></i></label>             <i class="mdi-navigation-close"></i>           </div>              <div id="results">               <ul class="results_list" style="display:none"></ul>             </div>          </form>       </li> 

here css:

<style> .search input:focus + .results_list { display: block }  .search .results_list {     display: none;     position: absolute;     top: 35px;     left: 0;     right: 0;     z-index: 10;     padding: 0;     margin: 0;     border-width: 1px;     border-style: solid;     border-color: #cbcfe2 #c8cee7 #c4c7d7;     border-radius: 3px;     background-color: #fdfdfd;     background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #fdfdfd), color-stop(100%, #eceef4));     background-image: -webkit-linear-gradient(top, #fdfdfd, #eceef4);     background-image: -moz-linear-gradient(top, #fdfdfd, #eceef4);     background-image: -ms-linear-gradient(top, #fdfdfd, #eceef4);     background-image: -o-linear-gradient(top, #fdfdfd, #eceef4);     background-image: linear-gradient(top, #fdfdfd, #eceef4);     -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);     -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);     -ms-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);     -o-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);     box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); }  .search .results_list li { display: block }   .search .results_list li:first-child { margin-top: -1px }  .search .results_list li:first-child:before, .search .results_list li:first-child:after {     display: block;     content: '';     width: 0;     height: 0;     position: absolute;     left: 50%;     margin-left: -5px;     border: 5px outset transparent; }  .search .results_list li:first-child:before {     border-bottom: 5px solid #c4c7d7;     top: -11px; }  .search .results_list li:first-child:after {     border-bottom: 5px solid #fdfdfd;     top: -10px; }  .search .results_list li:first-child:hover:before, .search .results_list li:first-child:hover:after { display: none }  .search .results_list li:last-child { margin-bottom: -1px }  .search .results_list {     display: block;     position: relative;     margin: 0 -1px;     padding: 6px 40px 6px 10px;     color: #808394;     font-weight: 500;     text-shadow: 0 1px #fff;     border: 1px solid transparent;     border-radius: 3px; }  .search .results_list span { font-weight: 200 }  .search .results_list a:before {     content: '';     width: 18px;     height: 18px;     position: absolute;     top: 50%;     right: 10px;     margin-top: -9px;     background: url("http://cssdeck.com/uploads/media/items/7/7bnkbjd.png") 0 0 no-repeat; }  .search .results_list a:hover {     text-decoration: none;     color: #fff;     text-shadow: 0 -1px rgba(0, 0, 0, 0.3);     border-color: #2380dd #2179d5 #1a60aa;     background-color: #338cdf;     background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #59aaf4), color-stop(100%, #338cdf));     background-image: -webkit-linear-gradient(top, #59aaf4, #338cdf);     background-image: -moz-linear-gradient(top, #59aaf4, #338cdf);     background-image: -ms-linear-gradient(top, #59aaf4, #338cdf);     background-image: -o-linear-gradient(top, #59aaf4, #338cdf);     background-image: linear-gradient(top, #59aaf4, #338cdf);     -webkit-box-shadow: inset 0 1px rgba(255, 255, 255, 0.2), 0 1px rgba(0, 0, 0, 0.08);     -moz-box-shadow: inset 0 1px rgba(255, 255, 255, 0.2), 0 1px rgba(0, 0, 0, 0.08);     -ms-box-shadow: inset 0 1px rgba(255, 255, 255, 0.2), 0 1px rgba(0, 0, 0, 0.08);     -o-box-shadow: inset 0 1px rgba(255, 255, 255, 0.2), 0 1px rgba(0, 0, 0, 0.08);     box-shadow: inset 0 1px rgba(255, 255, 255, 0.2), 0 1px rgba(0, 0, 0, 0.08); }  li > {     display: block; }  </style> 

photo:

trophus, social experience colored food

edit:

i realized above not problem. problem added "onblur" event trigger in searchbar triggered function called "destroy" here:

destroy = function() {     $('.results_list').empty();     $('.results_list').hide(); } 

this function works great doing designed introduced new problem - if click on link "blur" happens, destroying data needed know navigate to. (that assumption of what's happening). how can around this? links must work obviously, of course if hovers away list must hidden, destroyed. appears event trigger occurring faster redirect. appreciated.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -