R
R
Rafail Dunyashev2016-10-26 13:05:32
JavaScript
Rafail Dunyashev, 2016-10-26 13:05:32

How to include collapse.js?

It is required to make an accordion, for example, like here . But I can't figure out how best to include the collapse.js file, which is located in the vendor\bower\bootstrap\js folder.
I know about yii\bootstrap\Collapse, but I don't want to use a widget.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Maxim Fedorov, 2016-10-26
@qonand

Create your resource set , include the collapse.js file in it, and register it in the required place.
For example:

class CollapseAsset extends AssetBundle
{
    public $sourcePath = '@bower/bootstrap/js';
    public $js= [
        'collapse.js',
    ];

   .....
}

and in the right place
CollapseAsset::register($this);  // $this - объект представления

A
asd111, 2016-10-26
@asd111

I don't understand what the problem is. After all, your example uses bootstrap.min.js and jquery.min.js . Connect and no problem.

M
Maxim Timofeev, 2016-10-27
@webinar

There is also a strange option, but if you don’t want to bother with AssetBundle:
just add a widget to the view, without parameters, it will not render anything, but will connect its assets

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question