Back to AdminController class

Method saveOrderAjax

public void
saveOrderAjax
()
Method to save the submitted ordering values for records via AJAX.
Returns
  • void
Since
  • 3.0

Method saveOrderAjax - Source code

/**
 * Method to save the submitted ordering values for records via AJAX.
 *
 * @return  void
 *
 * @since   3.0
 */
public function saveOrderAjax()
{
    // Check for request forgeries.
    $this->checkToken();
    // Get the input
    $pks = (array) $this->input->post->get('cid', array(), 'int');
    $order = (array) $this->input->post->get('order', array(), 'int');
    // Remove zero PKs and corresponding order values resulting from input filter for PK
    foreach ($pks as $i => $pk) {
        if ($pk === 0) {
            unset($pks[$i]);
            unset($order[$i]);
        }
    }
    // Get the model
    $model = $this->getModel();
    // Save the ordering
    $return = $model->saveorder($pks, $order);
    if ($return) {
        echo '1';
    }
    // Close the application
    $this->app->close();
}