onchange function in dropDownList yii2

て烟熏妆下的殇ゞ 提交于 2019-12-12 05:19:13

问题


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,&quot;vente/devis&quot;,&quot;/performancia/web&quot;,&quot;ArticleByFamille&quot;)"

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!