Best practice for dialog via Jquery Post

Hi all.

Pretty new to Yii but loving it so far.

I was wondering if there was a way to recreate this in Yii, and/or the best practice. In my old site, wich im converting to Yii, I was passing dynamically created dialogs to the client side from an jquery post request that was the consumed by a function i had on the main page.

example function i used

function sysDialog(obj){

		 var dialog = '<div id="dialogBox"><div class="modal"> <div class="modal-header"> <a class="close" data-dismiss="modal">x</a> <h3>'+obj.title+'</h3> </div>';

		  dialog = dialog + '<div class="modal-body">'+obj.msg+'</div>';

		  dialog = dialog + '<div class="modal-footer">';

		  var i = 0;

		  var js = "";

		  for (var i in obj.buttons){

			  var css = "btn"

			  if ( i == 0){

				  var css = "btn btn-primary"

				  i = 1;



			dialog = dialog + '<a id="'+i+'" href="#" class="'+css+'">'+i+'</a>';

			js = js+'$("#'+i+'").click('+obj.buttons[i]+');';



	      dialog = dialog +' </div></div></div>';

	      js = js + '$("#dialogBox").modal("show");		  $( "#SiteHolder" ).draggable();';




I know Yii has the CJuiDialog widget for creating a dialog box but since i’m calling renderPartial on my view the JS is never generated.

My goals are:

  • Be able to support a JavaScript enabled page as well as static pages.

  • Flexible enough to change ui’s

Should I just create a custom view for my theme? or should I just hard code my JS into the controller within –




       /// return my java script for client side consumption


The latter option would require that a JS function be embedded in the main page to consume this information and call a dialog.

A little background…

The site im working on is used at service point to help patrons/customers as well as manage personal. because of this the page is only ever fully loaded once. (This was done because there are i-frames contained withing the main page that preload slower sites required to assist in assisting patrons/customers.) After that all parts of the page are loaded with Ajax calls. I have found this to be a pain in Yii since it only generates JS when a page is fully rendered.