I intend to submit a node edit form via an ahah enabled button but the content of the ckeditor-enbled body textarea is not being passed along. It works with ckeditor disabled.

How do I workaround this?

Help will be greatly appreciated.

$form['taxonomy']['calais'] = array(
    '#type' => 'submit',
    '#value' => 'Refresh Suggestions',
    '#ahah' => array(
	  'path' => 'tagging_plus/callback',
	  'wrapper' => 'tagging_plus-taxonomy-fields-wrapper',
          'effect' => 'fade',
    ),
);	  	

Comments

togbonna’s picture

Actually, now am able to pass the body textarea content along by calling this CKEditor JavaScript function
Drupal.ckeditorOff('edit-body').

(function($) {
  $.fn.tagging_plus = function() {
    return this.each( function(){
      // **************** Init *****************/
      var context = get_context($(this).attr('class'));
      
      if(context === null) {
        alert('cant initialize tagging_plus-widget: "'+$(this).attr('id')+'"..did you forget the "taggig-widget-$CONTEXT" class?');
        return;
      }
      // Our containers.
      var input_sel = '.tagging_plus-widget-input-'+context;
      var button_sel = '.tagging_plus-button-'+context;
      var wrapper_sel = '.tagging_plus-curtags-wrapper-'+context;
      var suggestions_wrapper_sel = '.tagging_plus-suggestions-wrapper-'+context;
      var target_sel = '.tagging_plus-widget-target-'+context;
      var suggest_class = 'tagging_plus-suggest-tag';
      var tag_class = 'tagging_plus-tag';
      var suggest_sel = '.'+suggest_class;
      var tag_sel =  '.'+tag_class;

      // Lets set all things up.
      bind_taglist_events();
      bind_button();
      update_tags();
      bind_enter();
      check_dublicates();
      /*
      $(button_sel).bind('click',function() {
    	  
      }
      */

      $(input_sel).val('');
      $(this).addClass('tagging_plus-processed');
      Drupal.ckeditorOff('edit-body');
      // **************** Helper methods *****************/
      //                   ...

    }
    );
  }
})(jQuery);

The problem now is that the code that calls this function (see above) is being called after the AHAH callback (on clicking the 'Refresh Suggestions' button). As a result you need to click the 'Refresh Suggestions' button twice for the body textarea text to be passed on (this clearly scores low on usability).

So I think the solutions could be:
(1). how to get the above code to execute right before the AHAH callback (Is there any 'beforeSubmit' functions for AHAH callbacks?).
(2). (less elegantly though) how to get the callback to run twice automatically on each click of the 'Refresh Suggestions' button.
(3). How to attach a 'blur' event to the CKEditor body textarea field. This would then fire the callback automatically thereby calling the above function before the user have to click the 'Refresh Suggestions' button.

I can't seem to figure out how to pull off any of the above.

Any other suggestion that would work would do.

a.d2000’s picture

Hello All,

I am also facing issue which is slightly different using AHAH submit. I am having my custom form with one textarea as a field. I have used CKEditor.

I am using AHAH to submit my form but in $_POST i m not getting value of that textarea field.

below is my textarea field.

$form['list']['email_body'] = array(
      '#type' => 'textarea',
      '#title' => t('Template body'),
      '#required' => TRUE,
      '#default_value' => $node->body,
      '#description'=> "Available tokens are",
      '#resizable' => FALSE,
    '#rows' => 5,
    '#cols' => 30,
     );
   
    $form['list']['format'] = filter_form(FILTER_FORMAT_DEFAULT, NULL, array('list', 'format'));

It would be a great help if anyone has any solution.

Thanks in advance.

a.d2000’s picture

AHAH + TinyMCE issue is resolved.

http://drupal.org/project/ahah_action : ahah_action module is useful to resolve the issue. You will get the values of TinyMCE editor in post variable.

mkesicki’s picture

@a.d2000 this tracker is about CKEditor module. Please don't insert post that are not related with CKEditor.

a.d2000’s picture

Sorry I didnt notice that. But still ahah_action module is useful to add beforeSubmit action for AHAH callback. In that may be you can disable your editor.

jordan8037310’s picture

a.d2000,

Can you post an example of what you did?

Best,
JR

jordan8037310’s picture

Issue summary: View changes

Added format tags to code.

mpaler’s picture

Issue summary: View changes

In your custom form code:

 $form['mail_document']['msg'] = array(
    '#type' => 'textarea',
    '#title' => t('Personal note'),
  );
  
$form['mail_document']['format'] = filter_form(FILTER_FORMAT_DEFAULT, NULL, array('mail_document', 'format'));

$form['mail_document']['submit' ] = array(
    '#type' => 'submit',
    '#value' => t('Send email'),
    '#ahah' => array(
      'path'    => ahah_helper_path(array('mail_document')),
      'wrapper' => 'cs-opps-admin-document-form-wrapper',
    ),
    '#id' => 'cs-opps-document-submit',
  );

  $options = array(
    'attributes' => array(
      'target' => '_blank',
    ),
  );

  drupal_add_js(array(
    'ahah' => array(
      'cs-opps-document-submit' => array(
       // ahah actions picks up submitextra, you define your_module_submitextra
        'submitextra' => 'your_module_submitextra'
      )
    )
  ), 'setting');

Then in your module's .js file

/*
 * implement ahah beforeSubmit see: https://www.drupal.org/node/1241678
 */
function your_module_submitextra(form_values, element, options){
  /* handle wysiwyg messge */
  $.each(form_values, function(i, m){
    if(m.name == $('#edit-msg').attr('name')){
      form_values[i]['value'] = CKEDITOR.instances["edit-msg"].getData();
    }
  });
}