0

How to save popover contents upon re-initializing? Here is my code and the popup contains a form. I want to keep the form values if user comes back to after filling some info...

$(this).popover({
    html: true,
    trigger: 'manual',
    placement: 'bottom',
    content: function () {
        var $contents = $('#popover_template').html();
        return $contents;
    }
}).popover('toggle');

I don't want any modal window etc. Is there a way to keep the contents of a form even if the popover is reopen.

Thanks.

davidkonrad
  • 83,997
  • 17
  • 205
  • 265
uiuxhub
  • 1,209
  • 2
  • 14
  • 24

1 Answers1

0

You can use the "hidden" event to detect when your popover closes, then set its content back to your #popover_template div.

$(this).popover({
  // your initialization code
}).popover('toggle')
  .on("hidden", function(e) {
     $('#popover_template').html($(this).html());
   });

References

How to attach a function to popover dismiss event (Twitter Bootstrap)

Bootstrap modal popover hide on close

Bootstrap Popover - Save HTML on close

Community
  • 1
  • 1
gknicker
  • 5,509
  • 2
  • 25
  • 41