I have the following div and input text inside it. The div has a popover, and I want to show it whenever the input text is in focus. If the input text is out of focus, I want to hide the popover. I am currently trying to do this with the following code:
HTML:
<div id="divParent" bs-popover
data-trigger="focus click"
data-auto-close="1"
data-placement="bottom"
class="pswd-popover"
data-template-url="people/user/user-profile/templates/password-requirements.html">
<rp-form-input-text
rp-model="page.userData.password"
config="page.formConfig.password">
</rp-form-input-text>
</div>
Model:
model.password = inputTextConfig({
id: "password",
fieldName: "password",
dataType: "password",
required: false,
maxLength: 24,
modelOptions: {
allowInvalid: true,
},
onFocus: model.getMethod("showPopover")
});
CONTROLLER:
vm.showPopover = function () {
var focus = true;
$(window).keyup(function (e) {
var code = (e.keyCode ? e.keyCode : e.which);
if (code == 9 && focus) {
$timeout(function() {
angular.element('#divParent').trigger('click');
}, 100);
focus = false;
}
});
};
The problem I'm running into is simply that the onfocus function runs through a tab. Because clicking on a div automatically triggers a popover. This is why I have a keyup function to determine if a div was clicked or accessible via TAB. Another problem is that I show and hide the popover by invoking the onclick div. How can I show and hide the popover of the parent div from the controller?