Custom Clinkpager + Ajax Update

Hi, I have a custom CLinkPager extending class, which is pretty much like the default but adds a <select> and <script> tag to the pager. Here’s the class:


public function init() {

        if ($this->nextPageLabel === null)

            $this->nextPageLabel = Yii::t('yii', '&rsaquo;');

        if ($this->prevPageLabel === null)

            $this->prevPageLabel = Yii::t('yii', '&lsaquo;');

        if ($this->firstPageLabel === null)

            $this->firstPageLabel = Yii::t('yii', '&laquo;');

        if ($this->lastPageLabel === null)

            $this->lastPageLabel = Yii::t('yii', '&raquo;');


        if ($this->header === null)

            $this->header = Yii::t('yii', 'Showing items {start}-{end} of {count} items.');


        if ($this->footer === null)

            $this->footer = 'Jump to: {pager}';


        $page_range = $this->getPageRange();

        $page_size = $this->getPages()->getPageSize();


        $this->header = str_replace('{count}', $this->getItemCount(), $this->header);

        $this->header = str_replace('{start}', ($page_range[1] + 1) * $page_size + 1, $this->header);

        $this->header = str_replace('{end}', min(($page_range[0] + 1) * $page_size, $this->getItemCount()), $this->header);


        if ($this->footer === null)

            $this->footer = '{pager}';


        $page_count = $this->getPageCount();


        $cur_page = $this->getCurrentPage();


        $pages = range(1, $page_count);


        $pager = CHtml::dropDownList('', $cur_page, array_combine($pages, $pages), array(

            'style' => 'width: 90px; display: none;',

            'id' => 'drop_pager',

            'onchange' => '$.fn.yiiGridView.update("' . $this->grid_id . '", {data: "' . $this->control . '_page=" + $(this).val()});',

        ));


        $pager .=

'<script>

$(".items select, #drop_pager").chosen({

    search_contains: true,

    disable_search_threshold: 10

});

$(".yiiPager li").each(function() {

    console.log("Parsing pager");

    if ($(this).prev().length && !$(this).prev().hasClass("hidden"))

        $(this).find("a").css({ borderBottomLeftRadius: 0, borderTopLeftRadius: 0 });

    if ($(this).next().length && !$(this).next().hasClass("hidden"))

        $(this).find("a").css({ borderBottomRightRadius: 0, borderTopRightRadius: 0 });

});

</script>';

Now, the problem is that the moment I use AJAX to update the GridView (for example, by actually using the pager), the <select> and <script> tags are not re-generated. I end up with the buttons, and "Jump to: " with no select box afterwards.

How can I solve this?

I’m looking for a way that wouldn’t require me to use onAjaxUpdate for every GridView I make, so that I can include it in the class and make it global and the “default” behavior.

Thanks in advance.