5

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!

  • 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 Jun 20 '15 at 12:22
  • I updated my question with What I tested. – Alex Jun 26 '15 at 12:44
2

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();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.