nohros / nsPopover

Popover dialogs for angularjs applications.
MIT License
126 stars 107 forks source link

Add callbacks for when a popover is opened or closed. #100

Closed gabehayes closed 9 years ago

gabehayes commented 9 years ago

Currently, it appears that there are two ways to hook into the opening of a popover.

  1. Use the ns-popover-angular-event, which will open the popover when the given event name is broadcasted on the $rootScope. You can listen to that event elsewhere and know that when it is called, the popover was also told to display.
  2. Use the ns-popover-scope-event, which will open the popover when the given event name is broadcasted on the $scope. As with angular-event, you can listen for that event and respond accordingly.

The problem with the two approaches above is that sometimes there are many popovers on the same scope, so unless you are using group ids, you may be triggering numerous popovers to display when you had only wanted to open one.

To remedy this, both ns-popover-angular-event and ns-popover-scope-event should parse the passed in values, so that you could bind to an event such as some:event:{{ some.id }}.

I found that this was a level of complexity that was beyond what I was looking to do.

Really, I just wanted to run callback methods when the associated popover was either opened or closed.

These proposed changes introduce the following attributes:

<div ns-popover
     ns-popover-on-open="onPopoverOpen()"
     ns-popover-on-close="onPopoverClose()"
></div>

The callbacks will be executed when the respective popover's displayer_.display or hider_.hide methods are called.