views:

169

answers:

1

Hello All, i m using tinymce editor on joomla component that behave strangly

tinymce is already present (automaticaaly) on page load ..now if i write something on tiny mce editor( eg: 'with tinymce') & then click on toggle editor button ( now simple text area appears) and i see <p>with tinymce</p>, now if i append some text (eg:'with tinymce but this time toggled') and click on submit button then i get only this string 'with tinymce' in post array, not the complete string 'with tinymce but this time toggled' .

means if i write something when tinymce present on page (let 'x' ) then toggle the editor now only text area appears) and edit X (let 'x+Y') and click on submit then i get only that string which has been written when tiny mce was present on page( means i get only 'x', not 'x+Y')

please tell me what i have to write in below code to get the complete string either it wriiten with tinymce or without tinymce

my code is given below

jQuery(document).ready(function(){    
jQuery("#add_cat").click(function() {
if(jQuery("#description_parent").is(":hidden")==false){ // if editor is shown then 
    var content = tinyMCE.activeEditor.getContent(); // get the content
    jQuery("#cat_description").val(content); // put it in the textarea
}
});

jQuery("#addCategoryForm").validate({
        rules: {
            category_name: {
                required: true,
                minlength: 2
            },          
            cat_description: "required"
        },
        messages: {
            category_name: {
                required: "Please write category name",
                minlength: "category name must consist of at least 2 characters"
            },
            cat_description:"Please write description"
        }
    });
});
</script>
<form action="" method="post" name="addCategoryForm" id="addCategoryForm"  >    
  <table >
    <tr>
        <th >Category Name :</th>
        <td ><input type="text" name="category_name" id="category_name" size="50"></td>
    </tr>       
    <tr>
       <th valign="top"><span class="mandatory">*</span>Description :</th>
       <td >
    <?php
        $editor =& JFactory::getEditor();
        $params = array('smilies'=> '0' ,'style'  => '0' ,'layer'  => '0' ,'table'  => '0' ,'clear_entities'=>'0');
        $value = isset($this->data['description']) ? $this->data['description'] : '';
        echo $editor->display('cat_description', $value,'400','300','20','20',false, $params);
    ?>
      </td>
    </tr>   
    <tr><td colspan="2"><input type="submit" name="add_cat" id="add_cat" ></td>
  </table>
  <input type='hidden' value='com_advertise' name='option' />
  <input type='hidden' value='advertise' name='controller' />   
  <input type='hidden' value='modifyCategory' name='task' />
  <input type="hidden" value='<?php echo $this->imageid; ?>' name="image_id" /> 
  <input type='hidden' value='<?php echo $this->categoryid; ?>' name='category_id' />   
  <input type="hidden" name="<?php echo JUtility::getToken(); ?>" value="1" />
</form>
+1  A: 

Hmmm. Tinymce uses a hidden textarea to store the editor content. I just have the guess that your joomla submit is not updating that textarea. In that case you will need to call tinymces save function before submitting. The code for that (as an event handler in tinymce plugin) could look like the following (you might need to use another suitabel editor event than onChange):

//call save using an event handler
ed.onChange.add(function(editor, event){
       editor.save();
});

// call save directly without handler
editor_instance = tinymce.EditorManager.getInstanceById('content'); // 'content' is used as default editor id, it might be another id

editor_instance.save();
Thariama
where do i put above code??
JustLearn
the first one is placed inside a custom tinymce plugin, the second one is javascript code you can invoke directly from your page (for example if you use the firebug console, be aware that you need the real editor id)
Thariama
@Thariama i didn't get u , `inside custom tinymce plugin` means in which file exactly?
JustLearn
have a look here at a howto write a plugin for tinymce:http://wiki.moxiecode.com/index.php/TinyMCE:Create_plugin/3.x . But i think best for you would be to call the second code from a console to see if that is the reason
Thariama
Thanks a lot for helping me...let me apply it
JustLearn