I need to detect if tinymce content has changed. I am using symfony 1.4, sfWidgetFormTextareaTinyMCE.
Part of my form has the following code:
$tiny_mce_config = 'theme: "advanced",' .
'theme_advanced_buttons1: "bold,italic,link",' .
'theme_advanced_buttons2: "",' .
'theme_advanced_buttons3: "",' .
'theme_advanced_statusbar_location : "none",'.
'cleanup: true,'.
'force_br_newlines: true,'.
'force_p_newlines: false,'.
'forced_root_block: "",'.
'valid_elements : "br,strong,b,em,i,a[href|title|target]"';
$this->setWidgets(array(
'intro' => new sfWidgetFormTextareaTinyMCE(
array(
'width' => '616',
'config' => $tiny_mce_config
)
)
));
Rendering in my template, I did this:
<?php echo $form['intro']->renderLabel('Introduction'); ?>
<?php echo $form['intro']->render(array('rows' => 3, 'cols' => 100)); ?>
<?php echo $form['intro']->renderError(); ?>
I tried putting onchange event to the original textarea, but it didn’t work.
Using a jQuery selector as @MichalTrojanowski says is the best way I think. It’s unobstructive.
You can also give the attribute from the
->render()method, as you did forcols&rows:By the way, I don’t think this method will be fired when user will edit content. Since TinyMCE re-create an iframe (or sort of) to handle the editor.
You might better have a look at the onChange event built inside TinyMCE. Something like these :