Yii Framework Forum: use CJuiDialog to send a message - How to link to a controller action? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

use CJuiDialog to send a message - How to link to a controller action? Rate Topic: -----

#1 User is offline   nettrinity 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 208
  • Joined: 15-March 11

Posted 25 October 2011 - 08:55 PM

I want to implement this feature:
user click the button on the page, than a dialog box pop up(e.g. CJuiDialog). User can input the short messang, and click 'send' button on this dialog window.
After the click, the message will be sent to its destination (e.g.: saved in database). Dialog box closed. Please refer to the photo.

By digging into many examples, I come up with the following code:

To initialize a CJuidialog
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
	'id'=>'mymodal',
	'options'=>array(
    	'title'=>'Joining A Firm',
    	'width'=>500,
    	'height'=>300,
    	'autoOpen'=>false,
    	'resizable'=>true,
    	'modal'=>true,
    	'closeOnEscape'=> true,
    	'overlay'=>array(
        	'backgroundColor'=>'#000',
        	'opacity'=>'0.8'
    	),
    	'buttons'=>array(
        	'Send'=>'js:function(){alert("OK");}',
        	'Cancel'=>'js:function(){$(this).dialog("close");}',	
    	),
	),
));
   
	echo '<span>Message to this company</span><br/>';
	echo CHtml::textArea('message');  // this generate the textarea
$this->endWidget('zii.widgets.jui.CJuiDialog');

?>


To call the dialog:

  <?php echo CHtml::Button('Join this firm',                    	
                    	array('onClick'=>'$("#mymodal").dialog("open");'
                        	)); 
?>


I feel it likes MVC in a CJuiDialog, but couldn't sort it out myself.
This is as far as I can go by myself. How to link the send button with a controller action? so that user message can be processed?


Thank you!

Attached File(s)


0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users