How to reload sidebar on modal close event

Answered

2 Comments

  • Ahmed Zaid
    User Group Leader Community Moderator
    Zendesk Luminary

    Hi Shreyash Secretary,

    The way I would do so is by listening to an event in the sidebar app and triggering it when the modal is closed.

    In your modal app:

    var modalClient = ZAFClient.init();
    var ticketSidebarClientPromise = modalClient.get('instances')
        .then((instancesData) => {

           var instances = instancesData.instances;
           for (var instanceGuid in instances) {
               
    if (instances[instanceGuid].location === 'ticket_sidebar') {
                   return modalClient.instance(instanceGuid);
               }
           }
        
    }
    );

    modalClient.on('modal.close', () => {
        ticketSidebarClientPromise.then((ticketSidebarClient) => {
           ticketSidebarClient.trigger('reload');
        });
    });

     

    In your ticket sidebar app:

    (var ticketSidebarClient = ZAFClient.init();
    

    // This loads the homepage the first time
    home();

    ticketSidebarClient.on('reload', () => {
      // This loads the homepage again when modal is closed
      home();
    });

    )();

    function home() {
      // Do stuff
    }

     

    I hope that helps.

    0
  • Shreyash Secretary

    Thanks Ahmed Zaid I had tried and was working. Thank you for your support.

    0

Please sign in to leave a comment.

Powered by Zendesk