# Embedding a popup meetings dialogue

**URL:** <https://community.hubspot.com/t/embedding-a-popup-meetings-dialogue/8411>\
**Category:** CMS Development\
**Created:** [April 6, 2018, 1:40pm UTC](https://community.hubspot.com/t/embedding-a-popup-meetings-dialogue/8411 "2018-04-06T13:40:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![grantfoster](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/grantfoster/32/99547_2.png) [@grantfoster](https://community.hubspot.com/u/grantfoster)\
**Post date:** [April 6, 2018, 1:40pm UTC](https://community.hubspot.com/t/embedding-a-popup-meetings-dialogue/8411/1 "2018-04-06T13:40:25Z")

</div>

I am trying to embed a popover meetings scheduling window. I can get as far as assigning an event handler to mousleave that will make my meetings window pop up but the issue I’m having is that even though I use a closure, the event keeps firing. You can see my code below and my page here: [https://preview.hs-sites.com/\_hcms/preview/template/multi?is\_buffered\_template\_layout=true&portalId=396606&tc\_deviceCategory=undefined&template\_layout\_id=5002014864&updated=1522960853443](https://preview.hs-sites.com/_hcms/preview/template/multi?is_buffered_template_layout=true&portalId=396606&tc_deviceCategory=undefined&template_layout_id=5002014864&updated=1522960853443)

```auto
var isOpen = false;function popup() {
 if (isOpen === false) {
 //wraps blur
 $('body').wrapInner('<div class=blur-all></div>');
 //shows overlay
 $('.meetings-iframe-container').prependTo('body').fadeIn(200);
 $.getScript('https://static.hsappstatic.net/MeetingsEmbed/ex/MeetingsEmbedCode.js');
 return isOpen = true;
 }
};

$(document).mouseleave(function() {
 popup();
 console.log(isOpen);
});

```

---

<div class="post-metadata">

**Author:** ![roisinkirby](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@roisinkirby](https://community.hubspot.com/u/roisinkirby)\
**Post date:** [April 25, 2018, 1:28pm UTC](https://community.hubspot.com/t/embedding-a-popup-meetings-dialogue/8411/2 "2018-04-25T13:28:35Z")

</div>

Thanks for sharing all that detail @grantfoster! @ndwilliams3 what would you advise here?

---

<div class="post-metadata">

**Author:** ![grantfoster](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/grantfoster/32/99547_2.png) [@grantfoster](https://community.hubspot.com/u/grantfoster)\
**Post date:** [April 25, 2018, 1:36pm UTC](https://community.hubspot.com/t/embedding-a-popup-meetings-dialogue/8411/3 "2018-04-25T13:36:38Z")

</div>

Hi guys!

I solved my own issue. I think what was happening was due to this line here:

`$('body').wrapInner('<div class=blur-all></div>');`

When I wrapped the body in this ‘blur-all’ div I had created, it somehow triggered React to reload. I assume this because in the console I could see ‘App started!’ twice. I think this was causing my embedded script to load and run twice.

To fix this - instead of wrapping the whole body in a new div container - I just used the jquery method insertBefore(); to add the deiv before the body and not wrap it. This solved my issue!
