Reputation: 2080
I am using tinymce editor in my Yii Web Application.
So my question is
I have a drop down box with different languages like English, Urdu, Spanish
and etc.
And there is a text Area below that drop down list.
I want to populate data in that text Area.
When I select any language, then it will display the description.
The below code works fine if i remove tinymce editor.
I have a code in my _form.php
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'sorah-form',
// Please note: When you enable ajax validation, make sure the corresponding
// controller action is handling ajax validation correctly.
// There is a call to performAjaxValidation() commented in generated controller code.
// See class documentation of CActiveForm for details on this.
'enableAjaxValidation'=>false,
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model,'language_id'); ?>
<?php
$mylang = array();
foreach($language as $lang)
{
$mylang[$lang->id] = $lang->language_name;
}
echo CHtml::activeDropDownList($model, 'language_id', $mylang, array(
'ajax' => array(
'type'=>'POST',
'url'=>CController::createUrl('Sorah/bktext'),
'update'=>'#Sorah_background_text', // here i think, it needs some changes. But how ?
// or do you know how to write here javascript statement ?
)));
?>
<?php echo $form->error($model,'language_id'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'background_text'); ?>
<?php echo $form->textArea($model,'background_text',array('rows'=>6, 'cols'=>50)); ?>
<?php echo $form->error($model,'background_text'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
So can you please help me, how i can solve my this problem.
Any help will be appreciated.
Thanks.
Upvotes: 0
Views: 1062
Reputation: 2080
To Populate data on tinymce editor in Yii when using Ajax, Its better to use Success statement.
'success'=>'js:function(data) { tinyMCE.get("Your_textArea_id").setContent(data); }',
You may also check below link to understand more clearly.
http://www.tinymce.com/wiki.php/API3:method.tinymce.Editor.setContent
Thanks
Upvotes: 2
Reputation: 181
Use activeId to get the id generated.
'update'=>'#'.CHtml::activeId($model,'background_text')
Also, using success instead of update will be a better idea.
Upvotes: 0