Strange Behavior On Render(Partial) And Widgets


my website contains an CActiveForm with an CJUI Slider Widget, which works fine.

This means: jQuery and jQuery UI is working at the page.

The user can now open an additional form by clicking an ajax-link, where an ajax-action gets the new form from server in oder to write the received data to an html element.

The PHP action (which generates the new form) runs an renderPartial:




Part of this ‘_part_Form’ view is an CJuiDialog with autoOpen=true. The content of this dialog is an selfmade widget, which generates the form with an slider (CJui widget), datepicker (CJui widget) and so on.

Back to the application: the user starts the ajax action, the server generates the form by using _part_Form View and the selfmadeWidget (containing the slider & datepicker widget) and autoopen the form.

…but nothing happens. On firebug I see: …slider() is not a function.

Which looks like, jQuery UI is not loaded. But: jQuery UI is loaded. Because the other slider on the webpage works (see first lines at this post).

So whats happens here? Why jQuery seams not to be available anymore?

If i load jQuery UI in _part_Form View again (by adding <script src=…> Tag), every works fine.

Why i have to load jQuery UI a 2nd time at the same webpage?

I have no Idea, how to continue debugging… :frowning:

Thank you for any kind of help.


does this answers your problems: ?

@redguy jup. that’s it. Thank you .But why i have to add those line, even if i use ‘scriptFile’=>false, on all the widgets?

but now i see the following strange thing:

By opening the new form the first time: everything is fine: CJui Slider and CJui dialog works.

Closing the dialog and open again (which results in an new ajax request to load the form) the slider and datepicker are not present (visible).

Debugging this problem i found out, that if i close an CJui Dialog, than the dialog still exists, but is not visible. So to remove the dialog completely, I use this CJui Dialog/jQuery option:

'dialogclose'=>'function(event, ui){$(this).dialog("destroy").remove();}'

…which destroys/removes the dialog, but datepicker and slider still exists. Probably this is the reason, why i don’t see those elements in the new (again) loaded form.


Does anyone know, how to remove an dialog completely with all his elements, which are generated by Yii widget and not insight the CJui dialog <div>?? (there are placed somewhere in the HTML code!..?!

Thank you, rall0r

//Edit: i found the following solution:

Because it looks like, there is no Yii-build-in support to add an onClose event, like ‘close’=>‘function()…’ or ‘closedialog’=> like written here:

in order to destroy/remove the form an close,

I decided to use the pure jQuery dialog feature (no Yii widget) in order to define an function on close, which will remove the dialog from the dom completely. Be re-opening the form it’s loaded again with all elements (slider, datepicker,…)