-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Toggle ButtonGroup inside Dialog : error #228
Comments
@fleuryc Can you please provide your code which produces the error? It'll help to reproduce it. |
@hijarian I'll try to do that ASAP |
Allright, here it is (I just copy/pasted the code examples for Dialog and ButtonGroup from the YiiBooster website) : // in my /site/index view file
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
'id'=>'mydialog',
// additional javascript options for the dialog plugin
'options'=>array(
'title'=>'Dialog box 1',
'autoOpen'=>false,
'buttons' => array(
array('text'=>'Close','click'=> 'js:function(){$(this).dialog("close");}'),
array('text'=>'Cancel','click'=> 'js:function(){$(this).dialog("close");}'),
),
),
));
$this->widget('bootstrap.widgets.TbButtonGroup', array(
'type' => 'primary',
'toggle' => 'radio',
'buttons' => array(
array('label'=>'Left'),
array('label'=>'Middle'),
array('label'=>'Right'),
),
));
$this->endWidget('zii.widgets.jui.CJuiDialog');
// the button that may open the dialog
$this->widget('zii.widgets.jui.CJuiButton', array(
'name'=>'btndialog',
'caption'=>'Open Dialog',
'onclick'=>new CJavaScriptExpression('function(){$("#mydialog").dialog("open"); return false;}'),
)); When I click on one of the buttons in the radio toggle button group, I get this JS error message (firebug) :
Thanks! |
I had the same problem and is because a conflict of jQuery UI (CJuiDialog) or another component of jQuery UI and Bootstrap. You have to include first jQuery UI and after Bootstrap in your html, i fixed loading on my form the jquery.ui script on the POS_HEAD with the next line of php code: Yii::app()->clientScript->registerCoreScript('jquery.ui', CClientScript::POS_HEAD); Thanks to that jQuery UI is registered first and bootstrap after, no more conflict. I hope it helps. |
@benrivero this might well solve the problem indeed, but I would prefer not to have to register any script in the head : this is a dirty performance killer solution... Anyway, I guess it's better to have something that works, event if not optimized, but this is still a (minor) bug to me... |
@benrivero you have no idea how you helped %) |
Okay, this is an example of another jQueryUI/Twitter Bootstrap integration problem, so I'll put it into the 2.0.0 milestone. This issue is a long-standing motherf*#$er. |
@hulyman @fleuryc @benrivero Apparently when fixing quite another error (the dreaded tooltips conflict) I forced the loading of jQuery UI before Twitter Bootstrap. So, this particular problem should disappear, too. @fleuryc I'm very sorry, it seems that the fix I just described degraded performance even more, because now jQuery UI is being loaded on any page YiiBooster includes it's assets, even if jQuery UI is not used on the site at all. :( However, for now I don't see any other solution for conflicts between jQuery UI and Twitter Bootstrap. |
Please, confirm whether this bug still happens on latest |
Hello @hijarian recently download the new version and I can confirm that the problem is fixed now. =) |
Seems that now it is done! |
Hi!
When I put a Toggle ButtonGroup widget inside a Dialog widget, and when I click on a button, I get this javascript error message :
Error: cannot call methods on button prior to initialization; attempted to call method 'toggle'
When I remove the dialog widget (put the ButtonGroup directly inside the page), everything works fine.
I read these :
The dialog
<div>
comes indeed after the<script>
(firebug copy/paste - the elements are actually closed and not empty...) :I don't know if that's the cause of the error, but it may be an issue...
Cheers!
The text was updated successfully, but these errors were encountered: