Yii Framework Forum: Cjuiaccordion In Ajax Call (Cjuidialog) - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Cjuiaccordion In Ajax Call (Cjuidialog) Rate Topic: -----

#1 User is offline   befi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 24
  • Joined: 10-March 11

Posted 15 January 2013 - 12:12 AM

I am using CJuiDialog to open a dialog on click and populate it with content retrieved with an ajax call:

CHtml::ajaxLink(
            $text,
            CHtml::normalizeUrl ($ajaxUrl),
            array (
                'success'=>'function(html){
                    $("#'.$dialogID.'").html(html);
                    $("#'.$dialogID.'").dialog("open");
                }',
            ),  
            array (
                'href'=>CHtml::normalizeUrl($url),
                'target'=>'_blank',
            )   
        );  


Now, in this ajax call, renderPartial is used to create an CJuiAccordion. However, the Accordion doesn't work, I just get the plain HTML code. I assume that since it's an ajax call with renderPartial, the jQuery code doesn't get included and executed.

Is there a simple way to achieve this?

Thanks!
0

#2 User is offline   befi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 24
  • Joined: 10-March 11

Posted 15 January 2013 - 12:27 AM

I found out :)

In case, somebody else has the same problem, adding the accordion call in the "success" callback does the trick:

CHtml::ajaxLink(
            $text,
            CHtml::normalizeUrl ($ajaxUrl),
            array (
                'success'=>'function(html){
                    $("#'.$dialogID.'").html(html);
                    $("#'.$dialogID.'").dialog("open");
                    $("#your-accordion-id").accordion([]);
                }',
            ),  
            array (
                'href'=>CHtml::normalizeUrl($url),
                'target'=>'_blank',
            )   
        );


0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users