问题
I have a function (getArticleByFamille) in event onchange dopDownList like this:
<?= $form->field($modelFamille, 'idFamille')->dropDownList(
ArrayHelper::map(Famille::find()->all(), 'idFamille', 'libelle'),
[
'prompt' => 'Sélectionner la Categorie',
'class' => 'chosen-select mb-15',
'onchange' => 'getArticleByFamille(this.value,"vente/devis","' . Yii::$app->getUrlManager()->getBaseUrl() . '","ArticleByFamille")'
]
)->label(false); ?>
but When I call this function, it not working and when I inspect I have this code:
onchange="getArticleByFamille(this.value,"vente/devis","/performancia/web","ArticleByFamille")"
quote was changed
回答1:
It is because occurs encoding (enabled by default).
Try this (not tested):
[
'prompt' => 'Sélectionner la Categorie',
'class' => 'chosen-select mb-15',
'onchange' => new \yii\web\JsExpression( 'getArticleByFamille(this.value,"vente/devis","' . Yii::$app->getUrlManager()->getBaseUrl() . '","ArticleByFamille")' )
]
来源:https://stackoverflow.com/questions/39773795/onchange-function-in-dropdownlist-yii2