public $testValue = 1234;
public function outputArray(array $array,$count = false) {
if ($count === false) { $count = count($array); }
return '{"success":true,"total":"'.$count.'", "testValue":"'.$this->testValue.'", "results":'.$this->modx->toJSON($array).'}';
}console.log('Test Value', this.store.reader.jsonData.testValue);This question has been answered by muzzstick. See the first response.
console.log(this.store.reader);
,listeners: {
render: function() {
if (this.store.getCount() == 0) {
this.store.on('load', function() {
console.log(this.store.reader.jsonData.testValue);
}, this, {
single: true
});
} else {
console.log('store already loaded');
}
}
}
var global = (function () {
return {
publicVal: null
}
})();
Ext.extend(Doodles.panel.Home,MODx.Panel, {
checkValue: function() {
MODx.Ajax.request({
url: Doodles.config.connectorUrl
, params: {
action: 'mgr/doodle/getValue'
}
, listeners: {
success: {
fn: function (response) {
if(response.message == 1234) {
this.loadGrid(); // another function you would define to load the grid
}
}, scope: this
}
}
});
}
});
<?php
class GetValueProcessor extends modProcessor {
public $testValue;
public function process() {
$this->testValue = 1234;
return $this->success($this->testValue);
}
}
return 'GetValueProcessor';
<?php
require_once dirname(__FILE__) . '/model/doodles/doodles.class.php';
class DoodlesIndexManagerController extends modExtraManagerController {
public $doodles;
public function initialize() {
$this->doodles = new Doodles($this->modx);
$this->addCss($this->doodles->config['cssUrl'].'mgr.css');
$this->addJavascript($this->doodles->config['jsUrl'].'mgr/doodles.js');
$this->addHtml('<script type="text/javascript">
Ext.onReady(function() {
Doodles.config = '.$this->modx->toJSON($this->doodles->config).';
});
</script>');
return parent::initialize();
}
public function getLanguageTopics() {
return array('doodles:default');
}
public function checkPermissions() { return true;}
public function process(array $scriptProperties = array()) {
}
public function getPageTitle() { return $this->modx->lexicon('doodles'); }
public function loadCustomCssJs() {
$this->addJavascript($this->doodles->config['jsUrl'].'mgr/widgets/doodles.grid.js');
$this->addJavascript($this->doodles->config['jsUrl'].'mgr/widgets/home.panel.js');
$this->addLastJavascript($this->doodles->config['jsUrl'].'mgr/sections/index.js');
}
public function getTemplateFile() { return $this->doodles->config['templatesPath'].'home.tpl'; }
}
Doodles.panel.Home = function(config) {
config = config || {};
Ext.apply(config,{
border: false
,baseCls: 'modx-formpanel'
,cls: 'container'
,listeners: {
render: function() {
this.checkValue();
}
}
,items: [{
html: '<h2>'+_('doodles.management')+'</h2>'
,border: false
,cls: 'modx-page-header'
},{
xtype: 'modx-tabs'
,defaults: { border: false ,autoHeight: true }
,border: true
,items: [{
id: 'main-tab'
,title: _('doodles')
,defaults: { autoHeight: true }
,items: [{
html: '<p>'+_('doodles.management_desc')+'</p>'
,border: false
,style: 'margin:20px 0 0 20px;'
}]
}]
}]
});
Doodles.panel.Home.superclass.constructor.call(this,config);
};
Ext.extend(Doodles.panel.Home,MODx.Panel, {
checkValue: function() {
MODx.Ajax.request({
url: Doodles.config.connectorUrl
, params: {
action: 'mgr/doodle/getValue'
}
, listeners: {
success: {
fn: function (response) {
console.log('The value returned from the processor is: '+response.message);
if(response.message == 1234) {
this.loadGrid();
}
}, scope: this
}
}
});
},loadGrid: function() {
var doodlesGrid = MODx.load({
xtype: 'doodles-grid-doodles'
,cls: 'main-wrapper'
,preventRender: true
,flex: 1
});
var tab = Ext.getCmp('main-tab');
tab.add(doodlesGrid);
this.doLayout();
}
});
Ext.reg('doodles-panel-home',Doodles.panel.Home);
