Views ajax "Drupal way"

Error message

  • Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; GeSHi has a deprecated constructor in require_once() (line 818 of /home/xenyomed/public_html/sites/all/modules/libraries/libraries.module).
  • Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; ctools_context has a deprecated constructor in require_once() (line 127 of /home/xenyomed/public_html/sites/all/modules/ctools/ctools.module).
  • Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; ctools_context_required has a deprecated constructor in require_once() (line 127 of /home/xenyomed/public_html/sites/all/modules/ctools/ctools.module).
  • Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; ctools_context_optional has a deprecated constructor in require_once() (line 127 of /home/xenyomed/public_html/sites/all/modules/ctools/ctools.module).
  • Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in _menu_load_objects() (line 579 of /home/xenyomed/public_html/includes/menu.inc).

WE HAVE MOVED!

Please visit our new Drupal Website at https://www.xenyo.com.

function modulename_crm_form($form , $form_state) {
  $form['notes'] = array (
    '#type' => 'textarea',
    '#title' => 'Notes',
  );
  $form['submit'] = array (
    '#type' => 'submit',
    '#value' => t('Add a note'),
    '#ajax' => array(
      'callback' => 'modulename_crm_ajaxcallback',
      'wrapper' => 'modulename-crm-form',
       'method' => 'replace',
    ),
  );
  return $form;
}
function modulename_crm_ajaxcallback($form, $form_state) {
  $values = $form_state['values'];
  /* do your logic here , example : save a node */
  $commands = array();
  $commands[] = ajax_command_invoke(NULL, 'crm_view_ajax', array($uid) );  //Drupal ajax framework api
  return array(
    '#type' => 'ajax',
    '#commands' => $commands
  );
}
 
/* js */
(function ($) {
  $.fn.crm_view_ajax = function() {
    alert('Do something here');
  }
})(jQuery);
Help Share this Article