R
R
Ruslan Absalyamov2018-06-15 17:21:14
1C-Bitrix
Ruslan Absalyamov, 2018-06-15 17:21:14

Why can't my js file be connected?

I added the code in the site template ( /local/templates/main/header.php )

Asset::getInstance()->addJs("/bitrix/js/jquery.mask.min.js");

The plugin itself is in the correct directory.
Added code to main.js
$(document).ready(function() {
...
$('.address_zip').mask('999999');
...
}

But in the console it gives me an error
Uncaught TypeError: $(...).mask is not a function
All my code is head
<head>
  <meta charset="UTF-8"/>
  <title><? $APPLICATION->ShowTitle() ?></title>
  <? $APPLICATION->ShowHead() ?>
  <?
  global $currPage, $isMainPage;
  $currPage = $APPLICATION->GetCurPage(false);
  $isMainPage = ($currPage == "/" ? true : false);
  Asset::getInstance()->addString('<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />');
  Asset::getInstance()->addString('<meta http-equiv="X-UA-Compatible" content="IE=Edge, chrome=1" />');
  Asset::getInstance()->addCss("https://cdnjs.cloudflare.com/ajax/libs/normalize/7.0.0/normalize.min.css");
  Asset::getInstance()->addCss("https://fonts.googleapis.com/css?family=Roboto:400,700&amp;subset=cyrillic");
  Asset::getInstance()->addJs("https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js");
  Asset::getInstance()->addCss("/slick.css");
  Asset::getInstance()->addJs("//cdn.jsdelivr.net/gh/kenwheeler/[email protected]/slick/slick.min.js");
  Asset::getInstance()->addCss("https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.formstyler.min.css");
  Asset::getInstance()->addJs("https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.formstyler.min.js");
  Asset::getInstance()->addCss("/style.css");
  Asset::getInstance()->addJs("/scripts.js");
  Asset::getInstance()->addJs("/main.js");
  Asset::getInstance()->addJs("/bitrix/js/jquery.mask.min.js");
  Asset::getInstance()->addString('<!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js" data-skip-moving="true"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js" data-skip-moving="true"></script>
    <![endif]-->');
  ?>
</head>

I just don't understand why he doesn't want to work. Other files are connected normally, but what I want to insert cannot be connected.
And yes, I looked in the html markup of the page, there is no way for it to connect this file and I don’t see it in the network either. How to be here?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question