Popup Vue Component

Popup is a popup window with any HTML content that pops up over App's main content. Popup as all other overlays is part of so called "Temporary Views".

Popup Vue component represents Popup component.

There are following components included:

  • f7-popup - popup element
Prop Type Description
<f7-popup> properties
tablet-fullscreen boolean Defines whether the popup should be displayed fullscreen on tablets or not
opened boolean Allows to open/close Popup and set its initial state
backdrop boolean Enables Popup backdrop (dark semi transparent layer behind). By default inherits same app parameter value (true)
closeByBackdropClick boolean When enabled, popup will be closed on backdrop click. By default inherits same app parameter value (true)
animate boolean Whether the Popup should be opened/closed with animation or not. Can be overwritten in .open() and .close() methods. By default inherits same app parameter value (true)
<f7-popup> methods
.open(animate) Open popup
.close(animate) Close popup
Event Description
<f7-popup> events
popup:open Event will be triggered when Popup starts its opening animation
popup:opened Event will be triggered after Popup completes its opening animation
popup:close Event will be triggered when Popup starts its closing animation
popup:closed Event will be triggered after Popup completes its closing animation

Open And Close Popup

You can control Popup state, open and closing it:

  • using Popup API
  • by passing true or false to its opened prop
  • by clicking on Link or Button with relevant popup-open property (to open it) and popup-close property to close it

Access To Popup Instance

You can access Popup initialized instance by accessing .f7Popup component's property.

Examples

<template>
  <f7-page @page:beforeremove="onPageBeforeRemove">
    <f7-navbar title="Popup"></f7-navbar>
    <f7-block>
      <p>
        <f7-button raised popup-open=".demo-popup">Open Popup</f7-button>
      </p>
      <p>
        <f7-button raised @click="popupOpened = true">Open Via Prop Change</f7-button>
      </p>
      <p>
        <f7-button raised @click="createPopup">Create Dynamic Popup</f7-button>
      </p>
    </f7-block>
    <f7-popup class="demo-popup" :opened="popupOpened" @popup:closed="popupOpened = false">
      <f7-page>
        <f7-navbar title="Popup Title">
          <f7-nav-right>
            <f7-link popup-close>Close</f7-link>
          </f7-nav-right>
        </f7-navbar>
        <f7-block>
          <p>Here comes popup. You can put here anything, even independent view with its own navigation. Also not, that by default popup looks a bit different on iPhone/iPod and iPad, on iPhone it is fullscreen.</p>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit...</p>
          <p>Duis ut mauris sollicitudin, venenatis nisi sed, luctus ligula...</p>
        </f7-block>
      </f7-page>
    </f7-popup>
  </f7-page>
</template>

<script>
  export default {
    data() {
      return {
        popupOpened: false,
      };
    },
    methods: {
      createPopup() {
        const self = this;
        // Create popup
        if (!self.popup) {
          self.popup = self.$f7.popup.create({
            content: `
              <div class="popup">
                <div class="page">
                  <div class="navbar">
                    <div class="navbar-inner">
                      <div class="title">Dynamic Popup</div>
                      <div class="right"><a href="#" class="link popup-close">Close</a></div>
                    </div>
                  </div>
                  <div class="page-content">
                    <div class="block">
                      <p>This popup was created dynamically</p>
                      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse faucibus mauris leo, eu bibendum neque congue non...</p>
                    </div>
                  </div>
                </div>
              </div>
            `.trim(),
          });
        }
        // Open it
        self.popup.open();
      },
      onPageBeforeRemove() {
        const self = this;
        // Destroy popup when page removed
        if (self.popup) self.popup.destroy();
      },
    },
  };
</script>