<p>If the page is rendered from a template that extends <code>_layouts/elementindex</code>, then the Element Index class instance is available at <code>Craft.elementIndex</code>. So all you’d need to do is include this in the settings object when creating your Modal instance:</p>

<pre class="lang-javascript prettyprint-override"><code>onHide: function() {
    Craft.elementIndex.updateElements();
}
</code></pre>

CC BY-SA 3.0
2016-04-05T11:39:03.743Z
2016-04-05T11:39:03.743Z
Brandon Kelly
<p>Is it possible to refresh an element's list when closing a modal? I have a modal ready with:</p>

<pre><code>onHide : function(){
    //but all what I tried doesn't work here

    //1: This will do the trick, but there is some bug with "Double-instantiating a select on an element" then the check box for the actions appear multiple times.
    Craft.elementIndex = Craft.createElementIndex('Plugin_ElementType', $('#main'), {
        context:        'index',
        storageKey:     'elementindex.Plugin_ElemenetType'
    });

    //2 I was searching for some global function as updateElements
    something like this: Craft.cp.updateElements()
    or: Craft.Plugin_ElementType.updateElements(); but no success

}
</code></pre>

<p>I need this because in that modal I change, delete data from my elements so I have to update the list, if is possible without to reload the page of course. Thank you in advance!</p>

CC BY-SA 3.0
2015-06-20T12:22:39.967Z
What did you try already? A reference to updateElements should work, as long as you're using the right instance of it.
Bob Olde Hampsink
CC BY-SA 3.0
2015-06-26T12:44:31.297Z
I updated my question with What I tested.
Alex
<elementtype><javascript><updating>
How to trigger updateElements when hide modal?
# How to trigger updateElements when hide modal?

(Asked by: username_0 on 2015-06-19)

Is it possible to refresh an element's list when closing a modal? I have a modal ready with:
onHide : function(){
    //but all what I tried doesn't work here

    //1: This will do the trick, but there is some bug with "Double-instantiating a select on an element" then the check box for the actions appear multiple times.
    Craft.elementIndex = Craft.createElementIndex('Plugin_ElementType', $('#main'), {
        context:        'index',
        storageKey:     'elementindex.Plugin_ElemenetType'
    });

    //2 I was searching for some global function as updateElements
    something like this: Craft.cp.updateElements()
    or: Craft.Plugin_ElementType.updateElements(); but no success

}

I need this because in that modal I change, delete data from my elements so I have to update the list, if is possible without to reload the page of course. Thank you in advance!

**Tags:** elementtype, javascript, updating
> **Comments:**
> **username_1**: What did you try already? A reference to updateElements should work, as long as you're using the right instance of it.  
> **username_0**: I updated my question with What I tested.  

---

## 1 answers

### Answer by username_2 on 2016-04-05. Score: 3

If the page is rendered from a template that extends _layouts/elementindex, then the Element Index class instance is available at Craft.elementIndex. So all you’d need to do is include this in the settings object when creating your Modal instance:
onHide: function() {
    Craft.elementIndex.updateElements();
}


---

