<p>I'm not sure what your Question is exactly and what your expected outcome is but to create a Modal you can use this HTML</p>

<pre class="lang-html prettyprint-override"><code>&lt;div id="my-awesome-modal" class="modal"&gt;
    &lt;div id="modal-body" class="body"&gt;
        &lt;header class="header"&gt;
            &lt;h2&gt;My Awesome Modal&lt;/h2&gt;
        &lt;/header&gt;
    &lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>and via JavaScript you can show it</p>

<pre class="lang-JS prettyprint-override"><code>//create it
var modal = new Garnish.Modal($('#my-awesome-modal')); 
modal.show();
</code></pre>

CC BY-SA 4.0
2019-02-23T18:21:22.793Z
I am not able to add any js event on my custom button which is created by adding a new action
inrsaurabh
CC BY-SA 4.0
2019-02-23T18:25:39.607Z
Why are you not able to do that?
Robin Schambach
CC BY-SA 4.0
2019-02-23T18:10:01.097Z
2019-02-23T18:10:01.097Z
Robin Schambach
<p>I created a new custom action.</p>

<p>A new button is added in <code>getAvailableActions()</code> as we can se in below screenshot in red marked rectangle, now when i click on that button 
 (<code>Cusotm Action</code>) i want to open a pop up box ( i used <a href="https://github.com/pixelandtonic/garnishjs/blob/master/src/Modal.js" rel="nofollow noreferrer">Default pop up</a> js lib.</p>

<p><a href="https://i.sstatic.net/ViGCW.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ViGCW.png" alt="custombutton"></a></p>

<p>Template File path : /craft/plugins/tagmanager/templates/_mergetags.twig</p>

<pre><code>{% includeJsResource "tagmanager/js/tagmanager.js" %}

    &lt;div class="btn menubtn btnMeregeTags" role="button"&gt;{{ "Merge Tags"|t }}&lt;/div&gt;
    &lt;div class="menu"&gt;
    &lt;div id="mergetags-modal" class="modal"&gt; 
        &lt;div id="modal" class="body"&gt;
            &lt;header class="header"&gt;
                &lt;h2&gt;Modal header&lt;/h2&gt;
            &lt;/header&gt;
        &lt;/div&gt;
    &lt;/div&gt;
    &lt;/div&gt;
</code></pre>

<p>js part</p>

<pre><code>$(function () {
  $modal = new Garnish.Modal($('#mergetags-modal')); //create a new modal
  $modal.show();
});
</code></pre>

<p><a href="https://i.sstatic.net/Iuz1z.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Iuz1z.png" alt="default pop up"></a></p>

<p>Not able to open pop up correctly.</p>

<p>Thank you.</p>

<plugin-development><craft2>
Open pop on click of custom action and get filled data
# Open pop on click of custom action and get filled data

(Asked by: username_0 on 2019-02-18)

I created a new custom action.
A new button is added in getAvailableActions() as we can se in below screenshot in red marked rectangle, now when i click on that button 
 (Cusotm Action) i want to open a pop up box ( i used Default pop up js lib.

Template File path : /craft/plugins/tagmanager/templates/_mergetags.twig
{% includeJsResource "tagmanager/js/tagmanager.js" %}

    {{ "Merge Tags"|t }}
    
     
        
            
                Modal header
            
        
    
    

js part
$(function () {
  $modal = new Garnish.Modal($('#mergetags-modal')); //create a new modal
  $modal.show();
});


Not able to open pop up correctly.
Thank you.

**Tags:** plugin-development, craft2

---

## 1 answers

### Answer by username_1 on 2019-02-23. Score: 1

I'm not sure what your Question is exactly and what your expected outcome is but to create a Modal you can use this HTML

    
        
            My Awesome Modal
        
    


and via JavaScript you can show it
//create it
var modal = new Garnish.Modal($('#my-awesome-modal')); 
modal.show();

> **Comments:**
> **username_0**: I am not able to add any js event on my custom button which is created by adding a new action  
> **username_1**: Why are you not able to do that?  

---

