Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ui.bootstrap popover close on click

I have this popover with template

<i class="fa fa-link" popover-placement="right" uib-popover-template="'newReferenceTemplate.html'" popover-title="New link"> Add new external reference </i>

So when I click on that link icon, a popover opens witht this tamplate

<script type="text/ng-template" id="newReferenceTemplate.html">
  <label>Title</label> <br>
  <input ng-model="link.Title"> <br>
  <label>Url</label> <br>
  <input ng-model="link.Url"><br>
  <i class="fa fa-floppy-o" > Save </i>
</script>

When I press that 'floppy' icon, I'd like to close the popover. Are there any ways of doing this?

All I can find on documentation is the popover-is-open value, but I don't know if I can use this somehow, any thoughts?

like image 402
sch Avatar asked Oct 13 '15 13:10

sch


People also ask

How do you close popover?

To hide the displayed popover, use the popover(“hide”) method.

How do I show popover on hover?

Set the trigger option of the popover to hover instead of click, which is the default one. Or with an initialization option: $("#popover"). popover({ trigger: "hover" });

How do I use popover in bootstrap?

To create a popover, add the data-toggle="popover" attribute to an element. Note: Popovers must be initialized with jQuery: select the specified element and call the popover() method.


1 Answers

Step 1 : Add popover-is-open="isOpen" to the trigger link.

<i class="fa fa-link add-link" 
        popover-placement="right" 
        uib-popover-template="'newReferenceTemplate.html'" 
        popover-is-open="isOpen"
        popover-title="New link"> Add new external reference </i>

Step 2 : When you click the floppy icon inside the popover, set isOpen to false:

This is the save icon of the popover:

<i class="fa fa-floppy-o" ng-click="save()"> Save </i>

This is in the controller:

$scope.save = function () {
  $scope.isOpen = false;  
};

See plunker

like image 103
Michael P. Bazos Avatar answered Oct 17 '22 08:10

Michael P. Bazos