Does anyone know if it is possible to open a select programmatically in angularjs. Ive tried
angular.element(el).trigger('focus');
angular.element(el).trigger('click');
angular.element(el).trigger('mousedown');
Nothing works.
I also tried
$scope.doSomething = function(){
setTimeout(function() {
var el = document.getElementById('test');
var e = document.createEvent("MouseEvents");
e.initMouseEvent("mousedown", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
worked = el.dispatchEvent(e);
}, 0);
}
The above set focus but do not open the select.
Is it possible?
Try this for Hover:
JS:
$(document).ready(function(){
$("#selectId").hover(function(){
$(this)[0].size=$(this).find("option").length;
});
$("#selectId").click(function(){
$(this)[0].size=0;
});
});
HTML:
<select id="selectId">
<option>Volvo</option>
<option >Saab</option>
<option>Mercedes</option>
<option>Audi</option>
</select>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With