Submitted by Jan on
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);
- Log in to post comments