sigal
(Alex)
April 16, 2012, 5:01pm
1
Hi:
How can I use the "events" from jQueryUI dialog in the CJuiDialog ?
I would like to implement this:
stackoverflow.com/ questions/4887332/disable-browser-scrolling-while-jquery-ui-modal-dialog-is-open
(sorry, my first topic … no links allowed )
p.d. if possible in all my cjuidialogs (that means, in main configuration file)
Thank you !
abennouna
(Abennouna)
April 18, 2012, 9:49am
3
Hello. According to the docs:
Have you tried that?
sigal
(Alex)
April 18, 2012, 1:31pm
4
In the components array of main configuration I use this:
'widgetFactory' => array(
'widgets' => array(
'CJuiDialog' => array('options' => array('open' => "function(event, ui) {alert('test open'); }", 'modal' => true, 'draggable' => false)),
),
),
but it does not work.
I think it’s because when you declare a jqueryui element you can just pass options, no events !
Events are declared after declaring it (jqueryui.com/demos/dialog/#event-create )
The thing is that jQuery allows to put the "open" in the options:
jsfiddle.net/ZGqdc/
But Yii extension does not pass to it …
sigal
(Alex)
April 18, 2012, 4:07pm
5
I found the problem:
When I put this in the configuration:
'widgetFactory' => array(
'widgets' => array(
'CJuiDialog' => array('options' => array('open' => 'function(event, ui) {alert('test open'); }', 'modal' => true, 'draggable' => false)),
),
),
it turns to this options array when the dialog is created:
'open': 'function(event, ui) {alert('test open'); }',
'closeOnEscape': true,
'modal':true,
'draggable':false
But for jQueryUI , the "open" definition needs to be without quotes:
'open': function(event, ui) {alert('test open'); },
'closeOnEscape': true,
'modal':true,
'draggable':false
So, I don’t know if this is a new feature or a bug … but maybe you can check if the “string” is a javascript function or not, and apply the quotes in each case.
sigal
(Alex)
April 18, 2012, 4:16pm
6
Solved.
You must use "js:" before to "remove the quotes"
'CJuiDialog' => array('options' => array('open' => 'js:function() { alert(jQuery) }', 'closeOnEscape' => true, 'modal' => true, 'draggable' => false)),
Kolyunya
(Oleynikovny)
April 8, 2014, 8:38am
7
I wish to know where this is documented…