Question

I had an issue when trying to incorporate multiple date picker which can be found here : http://multidatespickr.sourceforge.net/

The issue I had is explained in the following stackoverflow. : https://stackoverflow.com/questions/17920743/jquery-multiple-datepicker-selected-dates-not-loading-to-textbox

Since I didn't get any responses, I started digging in to code and figured out that yii's auto generating jQuery is the issue to all the problem.

So what I did is remove the following jQuery / jquery.min.js and included this. jquery-1.7.2.js

Now on console I get this eror

NetworkError: 404 Not Found - css/assets/819742eb/jquery.min.js"

but however I am able to get the multiple date picker worked which is my real need. :)

Now what I need is, since I just manually deleted and got this working but I wanted to know how to force a view file (index.php) in yii framework to load only the scripts that are defined in the page but not anything from main template or defined anywhere else.

Below is a html output and i only need the ones that are pointed in blue to be loaded inside a specific view.

enter image description here

Était-ce utile?

La solution

In your config in components array add

'clientScript' => array('scriptMap' => array('jquery.js' => false, ))

Then load what version you want in layout header:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>

For yii 1.1.13 and lower and for jquery 1.9+ you'll need to patch jquery.ba-bbq to resolve some conflicts.

What you did (manually remove jquery) is very bad. Revert this.

To exclude some scripts use scriptmap. It can be used in controller before actions render and in config file.

All global scripts (jquery,jquery-ui etc.) must be in header in main layout. Load only custom scripts or plugins in your views.

Autres conseils

Add in config/main.php

'components' => [
    'clientScript' => ['scriptMap' => ['jquery.js' => 'http://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js']],
]
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top