lordfriend / nya-bootstrap-select

An AngularJS select replacement which build select like dropdown component with collection and ng-model support
http://nya.io/nya-bootstrap-select/
MIT License
179 stars 82 forks source link

FIX: Need to double click on get focus in order to open the select list #169

Open Asscobara opened 7 years ago

Asscobara commented 7 years ago

app.directive ( 'nyaFix', [ '$timeout', function ($timeout) { return function (scope, element, attrs) { var timeFromLostFocus = new Date(); $( "#" + element[0].id ).focusin ( function() { $timeout ( function() { var currectTime = new Date();
if( currectTime.getTime() - timeFromLostFocus.getTime() > 150) $( "#" + element[0].id ).addClass('open'); }, 100 );

                    }
                );

                $( "#" + element[0].id ).focusout
                (
                    function() 
                    {
                        timeFromLostFocus =  new Date();
                    }
                );

                scope.$watch
                (
                    attrs.ngModel,
                    function()
                    {
                        $timeout
                        (
                            function()
                            {
                                $( "#"  + attrs.nyaFixSetFocusId ).focus();
                            },
                            250
                        );      
                    }   
                );
            };
        }
    ]
);  
Asscobara commented 7 years ago

Use in the HTML

  1. {{option.displayName}}