Jump to:

5513 Posts in 1732 Topics by 1218 members

Customising the CMS

SilverStripe Forums » Customising the CMS » LeftAndMain - Reload main panel from AJAX call

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 267 Views
  • Double-A-Ron
    Avatar
    Community Member
    604 Posts

    LeftAndMain - Reload main panel from AJAX call Link to this post

    I could do this by directly referencing the DOM, so this is just a check to see if there is a best practise way of reloading a LeftAndMain page on demand. I seem to remember a LeftAndMain::ForceReload method in 2.4 but it doesn't appear to be in 3.1.

    Quite simply, I have a button on a form with a click event tied to it in JS. It does not call the form action the button sits in.

    $('#Form_UserAssistSession_action_endUserAssistSession').unbind('click').live('click', function(){

       var form = $('#Form_UserAssistSession');

    $.ajax({
       url : 'admin/user-assist/endUserAssistSession',
        data : form.formToArray(),
        dataType : "json",
        success : function(json) {
       
           if(json.response == true) {          
              // Refresh main content panel
              
           } else if(json.response == false) {
              // Something happened - display error on screen
           }
           
        },
        error : function(json) {
           console.log(json);
        }
        });

    // Return false so no server-side form is processed.
    return false;
    });

    What I want to do is refresh the main panel of LeftAndMain (a form) at the end of this function.

  • Double-A-Ron
    Avatar
    Community Member
    604 Posts

    Re: LeftAndMain - Reload main panel from AJAX call Link to this post

    success : function(json) {

    if(json.response == true) {
    // Refresh main content panel
    form.removeClass('changed'); // to stop "are you sure" js message
    $('.cms-container').entwine('ss').reloadCurrentPanel();
    } else if(json.response == false) {
    // Something happened - display error on screen
    }

    },

    267 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.