Modules:
Popups API 6.x-2.0-alpha5
WYSIWYG 6.x-1.1

I managed to get popups called everytime there is a node and a edit-node link. The popup displays the node-edit page and i can change the title or change attachements. If i do not use any extra editor i can change text in the body and i can save it. But of course I want to design the text. Make it bold or italic etc. I use the WYSIWYG-module (version 6.x-1.1) for that. But if a popup gets called and i make changes to the text the changes are not saved. If I create a new node and the WYSIWYG is activated the text gets saved.

I could not find anything similiar to that on drupal.org.

Is this a bug? Can you use popups and WYSIWYG to change text?

How does the content from WYSIWYG gets saved properly? If i display the normal body edit textarea with firebug (it disappears with display:none which is caused by the activation of the WYSIWYG module) and make changes to the text it gets saved properly.

I posted the issue also on the Popups module page since it is very hard for me to decide which module is messing up.

Comments

twod’s picture

Version: 6.x-2.0-alpha1 » 6.x-1.1
Status: Active » Postponed (maintainer needs more info)

I'm having troubles understanding when this problem happens. Are you editing a node inside a popup created by Popups API when the changes are not saved?

When a form with a WYSIWYG editor is submitted the detach() method in the Wysiwyg.module editor implementation gets called. Exactly what happens in there depends on the editor, but in short it extracts the contents from the editing area and puts it back into the original textarea.

I can't really say much without knowing how to reproduce this.

Btw, you could try upgrading to Wysiwyg 6.x-2.0 and see if this still happens there. (Remember to move your editor libraries to the new location, see installation instructions.)

doublewhopper’s picture

Thank you for replying. I updated the Wysiwyg module. It works fine in the normal backend.

You need the Popups API module and add this to popups.module. This enables the WYSIWYG in the popups.

if (module_exists('wysiwyg')) {
    // unfortunately we need to manualy add the tinMCE script to get it working
	drupal_add_js($base_path.'sites/all/libraries/tinymce/jscripts/tiny_mce/tiny_mce.js','module','header',FALSE,TRUE,FALSE); 	
  	}

And of course WYSIWYG 6.x - 2.0 with an installed Tinymce in sites/all/libraries/tinymce.

Go to admin/build/block and add a new block. You should get a popup and the create block node. The Tinymce editor should be attached at the top of the body text area. Type in some text and hit save. Move your block into a region to see that the text has been saved. Click on configure (there should be an extra icon at the right side of it) to change the text. Hit save. The text did not change.

Hope my instructions are clear. Thank you for helping on this issue.

doublewhopper’s picture

I looked for that function you mentioned and found this.

Drupal.wysiwyg.editor.detach.tinymce = function(context, params) {
  if (typeof params != 'undefined') {
    var instance = tinyMCE.get(params.field);
    if (instance) {
      console.log("instance.save");
      instance.save();
      instance.remove();
    }
  }
  else {
    // Save contents of all editors back into textareas.
    console.log("triggerSave");
    tinyMCE.triggerSave();
    // Remove all editor instances.
    for (var instance in tinyMCE.editors) {
      tinyMCE.editors[instance].remove();
    }
  }
};

I added the console logs to see if those commands get executed. Somehow my Firebug console stays empty.

doublewhopper’s picture

I looked for that function you mentioned and found this in editors/js/tinymce-3.js line 70.

Drupal.wysiwyg.editor.detach.tinymce = function(context, params) {
  if (typeof params != 'undefined') {
    var instance = tinyMCE.get(params.field);
    if (instance) {
      console.log("instance.save");
      instance.save();
      instance.remove();
    }
  }
  else {
    // Save contents of all editors back into textareas.
    console.log("triggerSave");
    tinyMCE.triggerSave();
    // Remove all editor instances.
    for (var instance in tinyMCE.editors) {
      tinyMCE.editors[instance].remove();
    }
  }
};

I added the console logs to see if those commands get executed. Somehow my Firebug console stays empty if I create a new node (or block). In this case the content actually gets saved so it has to be another function which is handling the saving process.

doublewhopper’s picture

The console logs get displayed if you click on "disable rich-text" at the bottom of the text body area. The interface is using the classic Drupal editor then. The text changes made in the new (Tinymce) editor are saved and copied into the old editor. This is the functionality I am missing at the moment if we save a node/block.

twod’s picture

Assigned: Unassigned » twod

Hmm, so the actual detachment code is working, but it's not called when the form is submitted. This is just a guess but maybe the onsubmit handlers don't work (aren't attached) inside popups?
I'm sorry I don't have more time to debug this at the moment, but I'll get back to it as soon as I can.
Assigning this issue to me as a reminder...

doublewhopper’s picture

Status: Postponed (maintainer needs more info) » Fixed

Resolved.
http://drupal.org/node/509570

This issue is fixed. Thank you for your support.

twod’s picture

Just for the record, did you update to a more recent version of Wysiwyg module and it worked?

doublewhopper’s picture

Yes I did. But the problem was solved with the patch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.