How can I make the extension work with CTabView

Created by Brian Armstrong on on 2010-07-11
Keywords:
CTabView

Because of how Yii includes the scripts with registerScript, all the variables used for this extension are inside an anonymous javascript function. As such, they are out of scope for the rest of the document.

Because of this, we have to use Yii to insert the code we want to use into this same anonymous function. We can do this by using the same scripts that the extension uses. Replace '#tab2' with the selector for the tab in which the map is located.

<?php
$click_script = <<<SCRIPT
    $('#tab2').click(function(){
        google.maps.event.trigger(gmap, "resize");
    });
SCRIPT;
Yii::app()->getClientScript()->registerScript("resizemap_js", $click_script, CClientScript::POS_END);
?>

This adds an event to the tab to force google map to invalidate and redraw itself as soon as the tag is activated.