I have a function in my module.php file:
public function evo_admin_pb() {
$this->EE->load->library('db/cache_mproc', '', 'qodb');
$this->EE->load->model('store');
$this->EE->cp->set_breadcrumb($this->_base_url, lang('qo5_module_name'));
$this->EE->cp->set_variable('cp_page_title', lang('evo_admin_pb'));
$data = array(
'pizza_type_form_action' => $this->_form_base . AMP . 'method=evo_select_pizza_type'
);
$data['_theme_base_url'] = $this->_theme_base_url;
$results = $this->EE->db->query("SELECT type_extra_id, friendly_desc FROM exp_qo5_pbev_type_extras WHERE extra_type = 'Finisher' ORDER BY friendly_desc");
if ($results->num_rows() > 0) {
foreach ($results->result_array() as $row) {
$data['finishers'][$row['type_extra_id']] = $row['friendly_desc'];
}
}
$data['crust_images'] = $this->get_asset_dir('evo_pb/crust/', '', TRUE);
if(isset($_SESSION['evo_pb_admin_crust']) && isset($_SESSION['evo_pb_admin_size']) && isset($_SESSION['evo_pb_admin_finisher'])){
$data['evo_selected_crust'] = $_SESSION['evo_pb_admin_crust'];
$data['evo_selected_size'] = $_SESSION['evo_pb_admin_size'];
$data['evo_selected_finisher'] = $_SESSION['evo_pb_admin_finisher'];
}
else if ($this->EE->input->post('action', TRUE) == 'edit') {
error_log("edit");
$data['evo_selected_crust'] = $this->EE->input->post('crust', true);
$data['evo_selected_size'] = $this->EE->input->post('size', true);
$data['evo_selected_finisher'] = $this->EE->input->post('finisher', true);
}
error_log("data going into view") ;
error_log(print_r($data, 1));
return $this->EE->load->view('pizzabuilder/evo_admin_pb', $data, TRUE);
}
The function is called two ways: first way is from a link that changes the URL directly so something like http://my_site.com/ap.php?C=addons_modules&M=show_module_cp&module=qo5&method=evo_admin_pb. This works correctly and loads the template as shown in the last line of the function.
The other way is from another javascript function:
function editCrustConfig(size, crust, finisher) {
$.ajax({
type : 'POST',
url : EE.BASE + '&C=addons_modules&M=show_module_cp&module=qo5&method=evo_admin_pb',
dataType : 'json',
data: {
action: 'edit',
size: size,
crust: crust,
finisher: finisher
}
});
}
There are a series of HTML table rows generated in another view that each has a link which calls the js function like this: javascript:editCrustConfig( 'M', 'H', 'MA')
. This doesn't work correctly, and I'm not sure why. editCrustConfig
is running, and calling the evo_admin_pb
function. It's getting all the way to the end of the function, and the error logging of the data being passed in to the view is correct. The only thing that isn't happening is the view actually loading.
What am I doing wrong? (We're on 2.5.2.)