1

I use GWTBootstrap3 v0.9.1.

I want to display a Popover with content that is stored in database. So when user hovers an element for the first time a Popover is displayed with Please wait... info. Meanwhile I get the proper text from database and want to replace Popover's content with a new one.

I thought this code would do the trick:

popover.setContent(newText);
popover.reconfigure();

But it doesn't work: the popover disappears and is not displayed anymore.

I know there are solutions for Bootstrap users, but as I use GWT-Bootstrap I want to do it in GWT without using jQuery.

Community
  • 1
  • 1
Adam
  • 5,403
  • 6
  • 31
  • 38

3 Answers3

2

In cases like this I just write native javascript methods that the jquery stuff to make it happen.

Even better I change it in the GWT-Bootstrap library itself and do a pull request so its get merged in the main repo.

I did something like this in the past for GWT-Bootstrap3 and it got merged in the main repo pretty quickly.

Knarf
  • 2,077
  • 1
  • 16
  • 24
2

The subject is already answered but there is a GWT work around. The reconfigure method doesn't work well while the isAnimated property is true. Just turn it off at the initialization.

smottt
  • 3,272
  • 11
  • 37
  • 44
Yoplaboom
  • 554
  • 3
  • 13
1

I follow @Knarf's suggestion and use native method as I could not find pure GWT solution:

private native void updatePopover(Element element, String popoverHtml, boolean shown) /*-{
    var $popover = $wnd.jQuery(element);
    $popover.data('bs.popover').options.content = popoverHtml;
    if(shown)
        $popover.popover('show');
}-*/;

where:

  • element is the popover widget's element (the element that has the popover)
  • popoverHtml is the new content
  • shown indicates whether popover is visible during update

I keep track of visible state by ShowHandler and HideHandler:

uiPopover.addShowHandler(new ShowHandler() {
    @Override
    public void onShow(ShowEvent event) {
        popoverVisible = true;
    }
});
uiPopover.addHideHandler(new HideHandler() {
    @Override
    public void onHide(HideEvent event) {
        popoverVisible = false;
    }
});

EDIT: It's better to use ShowHandler and HideHandler instead of ShownHandler and HiddenHandler.

Adam
  • 5,403
  • 6
  • 31
  • 38