-
Notifications
You must be signed in to change notification settings - Fork 6.7k
close popover programmatically & only one popover open at the time #618
Comments
neither is currently possible? |
no, I'm afraid not |
Darn that's kind of a bummer.. popover without those two features has a very very limited use. |
@fxck If you care about this feature and care about having it in the project we would be happy to accept a pull request (of course one that has test as well as documentation / demo page update). Would be awesome to see your contribution! |
@fxck Looking at the tooltip code, I was able to achieve single popover functionality and also hide popover on click elsewhere in the body using the following code (I use jQuery as well).
If you want to do it without jQuery and using only angular jQlite, you can try the following code (maybe it could be added to $tooltipProvider.options as popover-mode, like the following:
Anyway, here's the non-jQuery version and a working plnkr:
You can see the above non-jQuery code live at: |
+1 for the option. I think it's a more natural behavior for popover (in some usecases). In the meantime I will use the hack @vchatterji posted. |
+1 for the option. |
to have only one popover open at a time: popover-trigger="focus" |
If using "focus" as trigger the popover window will not remain open. So I think just a simple "focus" won't do if you would like a single popup to show up which will remain open. It should be possible to set focus on the content of the popover to keep it open. Until it looses focus, it should remain open. What do you think? |
+1 |
3 similar comments
+1 |
+1 |
+1 |
+1 hot solution ☕ # on click popover button
$ '.btn-popover'
.on 'click', ->
$ '.btn-popover'
.not @
.popover 'hide' |
@igorbelikov What kind of code is that, especially the annotation? |
@tmundt CoffeeScript - http://coffeescript.org/ |
+1 |
@vchatterji In your solution here, I found everything works fine, except that : angular.element(this).scope().tt_isOpen = false; when I tracing the scope(), there is no property called tt_isOpen, not sure if it because something has changed over the last year. Now if your set trigger map as : click -> click, you open the popover by clicking, and click somewhere else on the screen does close it (removing it from the DOM I believe) , however the state of of popover remain : isOpen = true. This results that next time you'd click twice to make the popover appear again. I'm not able to figure how to fix this. Hope there is a better way of doing this. |
Infuriating problem that should have been fixed long ago. On 0.12.1 I'm completely stuck as I have no access to tt_isOpen (or isOpen). Why can't I just trigger a close on the elements? |
+1 2015-04-23 11:46 GMT+02:00 thetaylor82 [email protected]:
|
tt_isOpen was removed, they use an "isOpen" attribute and I believe it's not in the same scope as before, anyway, lot's of trial and error leed us to this code which works unless you use the "append to body" attribute... (call hidePopovers from your global click-handler))
|
hmm I am using the new
@vchatterji Thank you for your code there. |
Any fixes if I use append to body? None of these seems to be working for me. |
will this work ? http://stackoverflow.com/questions/20939754/good-way-to-dynamically-open-close-a-popover-or-tooltip-using-angular-based, not sure, but this one works for me, #590, basically put a ng-click inside the template. |
@windmaomao it works like a charm. Unless you want to use a template. I'm investigating here right now. |
+1 |
1 similar comment
+1 |
As need for more control over popovers is quite common and there seem to be no progress on adding it to angular-ui repo I created a mini directive that can be used to open/close popovers programmatically: https://github.com/Elijen/angular-popover-toggle Suggestions are welcome :) |
Hello guys, any news about closing popovers on clicking outside? Best, |
@billyshena Closing on clicking outside is little bit more complicated as you will most likely need to add Here is a plunkr: http://plnkr.co/edit/kU9D8Av0fJI76wT8YlHa?p=preview |
@billyshena sorry, I use the same code as I pasted above, It just works for the first time, but not for the second time ... :/ |
@Elijen: I've used your plunkr as an example and it seems to work (even tho it's kind of tricky). Thanks for your code sample ! Are there gonna be any updates on this repo about implementing additional features to the popover? |
@billyshena The issue #590 is without any response from angular-ui team for 1 year and half. So I doubt there will be any progress on this. That's why I created the bower package. |
it is solved by adding data-trigger="focus" |
@Elijen : Mhh I see, thanks again then ! |
@Elijen Wow. You are an absolute genius! Thanks so much for this. I spend like two days on this issue (having built the rest of my app in 5). It is mind-blowing how something this trivial could be so ridiculously complicated. |
yes this is possible $(".popover").each(function(index){
// Element is current element on which popover will open.
|
This might be of help: https://github.com/Elijen/angular-popover-toggle |
Here is another implementation of Elijen's directive, ng-click on body was not working well for me so i had to change it a little. Here we don't have to hide the popover in a parent controller.
|
+1 |
Please do not +1 issues. It doesn't add anything to the discussion and clutters the thread. Thank you. |
@smohamali, we have the |
@icfantv Nope, I missed that in the documentation. Even easier. Thanks for the tip 👍 |
No worries. It's always a good idea to carefully check both that and the changelog to see what's present and what's changed. Especially in two years. That's an eternity in OSS. |
To open only one popover at a time: |
currently popover-trigger is expression so |
@MikhailRoot thank you for that. |
somehow i created one example for my need. i used this code: $('.btn').on('click', function (e) { |
To programatically close the popover you can use this dirty hack:
|
What I did was I set the tooltip-trigger="'none'" and change the tooltip-is-open="true" value based on the click. |
is there any way to do these? I would like to have a "x" button inside the popover to close it and I would want all other popover to be closed when I open a new one..
The text was updated successfully, but these errors were encountered: