Ad

OctoberCMS Partial Not Updating

- 1 answer

I have an issue returning a partial update from ajax call

        $.request('onClientChange', {
            data: {thisClient:thisClient}, 
            update: {sessionlist: '#sessionlist'},
            success: function() {
            //alert(' Made it');
            }
        });

The handler onClientChange looks like this

function onClientChange(){
$currentClient  =  post('thisClient');
$this['currentClient']  =  $currentClient;
 $sessionSql  =  "SELECT * FROM hdl_sessions where ClientID  =  $currentClient";
 $sessionDataset  =  $this->fetchData($sessionSql);
 $this['sessionDataset']  =  $sessionDataset;

}

The data returns directly to $sessionDataset and looking at the network tab in Chrome, I can see the partial data (an updated table structure) returning via the XHR log. The HTML table data renders fine statically when pasted into a blank page. It doesn't appear in the div marked by the ID

                <div id = "sessionlist" class = "table-responsive">
                    {% partial "sessionlist"  %}
                </div>

Any help gratefully received

Ad

Answer

use complete function instead of success function in javascript API

$.request('onClientChange', {
    data: {thisClient:thisClient}, 
    update: {sessionlist: '#sessionlist'},
    complete: function() {
    //alert(' Made it');
    }
});
Ad
source: stackoverflow.com
Ad