3

i doing ajax call and render view page in modal popup. but in this view page all js and css files are included. so in main page and ajax view page, js file got conflict.

i know how to disable js file in view page in yii-1.00

like this one

Yii::$app()->clientScript->scriptMap['jquery.js'] = false;
Yii::$app()->clientScript->scriptMap['yii.js'] = false;

but i dont know how to do this is in yii2.

so how can i do this.

thanks in advance.

3 Answers 3

2

This will disable bundle which conflicts others.

Write below code in particular page in where you want to disable the JS files.

unset($this->assetBundles['yii\bootstrap\BootstrapAsset']);
unset($this->assetBundles['yii\web\JqueryAsset']);
Sign up to request clarification or add additional context in comments.

Comments

0

if you want to exclude the assets which are registered on the layouts you can use return $this->renderPartial("view"); from your controller action.

render partial

otherwise if your view contain other Javascripts/css files you want to inject into the rendering result you may use return $this->renderAjax("view") instead

render ajax

1 Comment

thanks Nader, i already try this. but due to ajax call, some jquery render two times, so i want to just disable that repeat one.
0

for Yii2 //in controller you can use this line...It will not reload assets with renderAjax.

\Yii::$app->assetManager->bundles = false;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.