html - How to call ng-click before ng-blur? -


i've created text input suggestions appearing while typing (just on google - writing , suggests text).

<input id="smartbar" ng-focus="showsuggestions=true" ng-blur="showsuggestions=false" ng-model="smartbar" ng-keydown="smartbarkeydown($event)" focus-on="smartbar" />                 <table class="suggestionlist" ng-show="showsuggestions">                     <tr ng-repeat="sg in suggestions" ng-class="{highlighedsuggestion: $index == highlightedsuggestion}" ng-click="suggestionclicked($index)">                         <td ng-repeat="nt in sg.notetags" style="padding: 0rem 1rem">                             {{nt.tag.name}}                         </td>                     </tr>                 </table> 

i want add possibility click on 1 of "suggestions" (there ng-click attribute in < tr> html attribute). unfortunately, ng-blur seems work earlier ng-click, when click on 1 of options, input loses focus , suggestionlist becomes invisible before click detected.

how can detect click before hiding suggestionlist?

you cannot. however, can use ngmousedown instead of ngclick achieve desired functionality:

html:

ng-mousedown="suggestionclicked($index, $event) 

js:

$scope.suggestionclicked = function(index, evt) {     //detect left click     if(evt.which === 1) {         //your code     } } 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -