Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Cactiveform Dependent Dropdown Won't Work Inside Pjax'ed Content

$
0
0
here's my dependent dropdown php code:

<?php $find= new SomeModule;
$form=$this->beginWidget('CActiveForm', array(
'action'=> Yii::app()->createUrl('someurl'),
'method'=>'post',
'id'=>'filter-id',
'enableAjaxValidation'=>true,
)); ?>

<?php
echo $form->dropDownList($find,'category',
CHtml::listData(BaseCategory::model()->findAll(array(
'order' => 'name',
'condition'=>'type=:postID',
'params'=>array(':postID'=>1),
)), 'id', 'name'),
array(
'prompt'=>'Select Category',
'ajax'=>array(
'type'=>'POST',
'url'=>CController::createUrl('someurl/searchCategory'),
'update'=>'#'.CHtml::activeId($find,'category2')
),
)
);
?>
<?php
echo $form->dropDownList($find,'category2', array(), array(
'prompt'=>'Select Sub Category',
)
);
?>


I need to place this php code inside pjax content. Working fine when the page refreshed. But when it's loaded using pjax, this dependent dropdown won't work.

question:

How to make this dependent dropdown working when its loaded using pjax? What code should I add in:

$(document)
.on('pjax:success', function() {

})


to make this dependent dropdown works? Is there any script to "reload" this php code, so the dependent dropdown works? Or is there another solution?

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>