Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an option to not destroy the popover content's DOM when hiding the popover #16791

Closed
DominikVogt opened this issue Jul 9, 2015 · 4 comments

Comments

@DominikVogt
Copy link

Bootstrap v3.2
When I hide the popover with $(..).popover('hide'); the popover is removed from dom. When i reopen the popover with $(..).popover('show'); the changed content (eg. checked checkbox) is not shown, because the popover had been removed from dom.

asked allready on stackoverflow: http://stackoverflow.com/questions/31310958/bootstrap-popover-is-removed-from-dom-on-close

Any solution to this?

@cvrebert cvrebert added the js label Jul 9, 2015
@cvrebert
Copy link
Collaborator

cvrebert commented Jul 9, 2015

Bootstrap v3.2

Bugs are only accepted against the latest version of Bootstrap (currently v3.3.5). In the future, please upgrade before filing a bug.

@cvrebert cvrebert changed the title bootstrap popover is removed from dom on close Provide an option to not destroy the popover content's DOM when hiding the popover Jul 9, 2015
@DominikVogt
Copy link
Author

I found a solution to this. Im not quite sure if the content is changed in ..data('bs.popover').options.content according to the changes made in the popovercontent. But for me it didnt, because I have checkboxes, which do not change in html dom.

So I changed the options.content on hide.bs.popover.

If it doesnt work for the newest version as well, this might be something to take into account

$(elem).on('hide.bs.popover', function (e) {
    var popover = $(this);
    var popoverContent = popover.data('bs.popover').$tip.find('.popover-content');
    var checkboxes = popoverContent.find("input[type=checkbox]");
    checkboxes.each(function(){ 
        var checkbox = $(this);
        var checked = checkbox.prop('checked');
        checkbox.attr('checked', checked);
    });
    popover.data('bs.popover').options.content = popoverContent.html();
});

Needs to be done for all elements.

@cvrebert
Copy link
Collaborator

cvrebert commented Jul 9, 2015

Please include the value of htmlOptions in your original example.

@cvrebert cvrebert added the v3 label Aug 19, 2015
@mdo
Copy link
Member

mdo commented Sep 5, 2016

Bootstrap 3 is no longer being officially developed or supported.

All work has moved onto our next major release, v4. As such, this issue or pull request is being closed as a "won't fix." For additional help and support, we recommend utilizing our community resources. Thanks for your understanding, and see you on the other side of v4!

<3,
@mdo and team

@mdo mdo closed this as completed Sep 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants