dropDownList AJAX update+ renderPartial + ETootip (js) widget

Hi Guys,

I have a problem with ‘dropDownList AJAX update + renderPartial + ETootip (js) widget’ combo.

I read manny topics, but unfortunately I haven`t found the solution yet.

The problem:

I use "ETooltip" widget. I also have a dropDownList in my page with AJAX (this is a filter). At first time when user loads the page, "ETooltip" works perfectly. But if user select something from the dropDownList and the main content is reloaded (refereshed) with renderPartial, then "ETooltip" doesn`t work.

I collected the realted code parts:

Update_mt action is a basic controller action:


  public function actionUpdate_mt(...) {

  	$this->render('update_mt_view',array(...));

  }

In update_mt_view view, I use my custom menu widget (it is not the page navigation menu, it is something else. I don`t want to reloaded it if user use filter) and I included another view file ( mt_table_update ):


  $this->widget('UpdateMenu', array(...));


  include 'mt_table_update.php';

mt_table_update contains the dropDownList and #results div, which is refreshed if user use dropDownList. ETooltip is also used within #results div:




<div id="results">


   print CHtml::dropDownList(

                              'listname',

                              $filter,

                              $options_array,

                              array(

                                    'class' =>'ddlist',

                                    'ajax'  => array(

                                        'type'  =>'POST',

                                        'url'   =>CController::createUrl('MTUpdateRefresh'), //url to call.

                                        'data'  => array("listname" => 'js:jQuery(this).val()'),

                                        'update'=>'#results',

                                    )

                             ));

                             

    $selector = "#tooltip img[title]";

    $this->widget('ext.ETooltip.ETooltip', array( "selector"=>$selector));


    <div id="tooltip">

        <img src="<?php print Yii::app()->request->baseUrl ."/images/info.png"; ?>"

          title="<h1>This is my tooltip text with HTML tags</h1>" />

    </div>                               

</div>



So it works perfectly, when user loads the page. Tooltip is cool.

But when user select something from the dropDownList and page is refreshed, than Tooltip doesn`t works.

dropDownList AJAX action use MTUpdateRefresh controller action, which is reloaded only mt_table_update with renderPartial (to refresh #results, which contains ETooltip ):




  public function actionMTUpdateRefresh() {

    $this->renderPartial( 'mt_table_update', array(...), false, true );

  }



Any help would be good!

Thanks!

Hi

I had a similar problem not with yii but also with the jquery tooltip plugin so still the same.

My solution was to call the javascript .tooltip() function again after ajax content was loaded. In your case this would mean you have to call the ETooltip widget again or you can simply try to call $(".selector").tooltip(…options…); in the ajax success callback.

An other possible solution could be to adjust the ETooltip extension and add a method which do this for you automatically (e.g. by checking if request is an AJAX one) or by calling this custom method yourself.