lloydi12345
(Gilbertmarpuri)
December 28, 2015, 9:10am
1
I would like to update partially the page in my _create.php
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'device_type')->dropDownList($deviceTypeModel, [
'onchange' => 'show($id)']
);?>
<?php ActiveForm::end(); ?>
which calls the function on my controller
function actionShow($id)
{
$searchModel = new Object;
$dataProvider = $searchModel->search(Yii::$app->request->queryParams, $id);
return $this->renderPartial('service', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
ilaiyaraja
(Ilaiyamdu)
December 28, 2015, 10:08am
2
<?= $form->field($model, 'device_type')->dropDownList($deviceTypeModel, [
'onchange'=>'$.get( "'.Yii::$app->urlManager->createUrl('YourControllerName/show?id=').'"+$(this).val(), function( data ) {
$( "#DivName" ).html( data );
}',
]);?>
'
lloydi12345
(Gilbertmarpuri)
December 29, 2015, 12:56am
3
<?= $form->field($model, 'device_type')->dropDownList($deviceTypeModel, [
'onchange'=>'$.get( "'.Yii::$app->urlManager->createUrl('YourControllerName/show?id=').'"+$(this).val(), function( data ) {
$( "#DivName" ).html( data );
}',
]);?>
'
Thanks for the reply! What should I place under DivName by the way?
ilaiyaraja
(Ilaiyamdu)
December 29, 2015, 4:14am
4
Displaying Renderpartial page "service " in that div of my _create.php
lloydi12345
(Gilbertmarpuri)
December 29, 2015, 4:30am
5
I tried it but nothing is happening. What should I do?
<?= $form->field($model, 'device_type')->dropDownList($deviceTypeModel, [
'onchange'=>' $.get("'.Yii::$app->urlManager->createUrl("asdf").'")',
])
I tested the onchange property and placed a random url but I don’t know if it does anything since it does not prompt an error even though the url is invalid.