R
R
Ruslan2017-08-15 19:22:57
JavaScript
Ruslan, 2017-08-15 19:22:57

How to make a JS function from View see a function that is in a script.js file?

I am using Yii2. dop.phpThere is a JS script in the view :

(function handlerUrl() {
        var url = window.location.href;

        if(url.search( /faq/ )) {
          .....................
            accordion(anchorEl.parent());
        }
    })();

and in the file script.jsthat I include at the end of the page, there is the code:
$(function () {
function accordion(clickEl) {
...................
}
});

How to make the function handlerUrl()see the accordion?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Decadal, 2017-08-15
@Decadal

Your function is closed in function scope

$(function () {

//...

});

for starters, you should move the accordion function to the top so that other scripts can see it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question