Cjuibutton Error

I Have this button inside every tab using the CJuiTabs extension and everything works fine. The problem started when I decided to convert this CHtml::button into a CJuiButton


echo CHtml::button('Add New Model', array('id'=>"myModel_{$model->id}", 'onclick'=>"{doMyStuff(this); $('#myDialog').dialog('open');}"));

This is the code of the CJuiButton


$this->widget('zii.widgets.jui.CJuiButton',array(

    'name'=>'myModel',

    'id'  =>"myModel_{$model->id}",

    'caption'=>'Add New Model',

    'buttonType'=>'button',

    'onclick'=> new CJavaScriptExpression("function(){doMySutff(this); $('#myDdialog').dialog('open');}"),

    'htmlOptions'=>array('style'=>'background:#0064cd;color:#ffffff;'),

));

I already removed the CHtml::button and for some reason I get the error “Uncaught Error: cannot call methods on dialog prior to initialization; attempted to call method ‘open’”

Dialog is already declared once in the file and it works fine if I use the CHtml::button.

Does anyone have any idea of what I’m missing here or how to prevent this error but still use the CJuiButton?

Try adding TRUE param to your widget:




$this->widget('zii.widgets.jui.CJuiButton',array(

    'name'=>'myModel',

    'id'  =>"myModel_{$model->id}",

    'caption'=>'Add New Model',

    'buttonType'=>'button',

    'onclick'=> new CJavaScriptExpression("function(){doMySutff(this); $('#myDdialog').dialog('open');}"),

    'htmlOptions'=>array('style'=>'background:#0064cd;color:#ffffff;'),

), TRUE);



Thanks man… that worked perfect. I just needed to add an


echo;

before the widget but the error is gone.

Thanks Sir!

Excellent!

B)