ogarich89
@ogarich89
Front-End Developer

Правильно ли я использую require.js?

requirejs.config({
    paths: {
		jquery: 'jquery/dist/jquery.min',
        formstyler: 'jquery.formstyler.min',
        ymaps: '//api-maps.yandex.ru/2.0/?load=package.full&lang=ru-RU'
    },
    shim: {
        'formstyler': {
            deps: ['jquery']
        },
        'ymaps': {
            exports: 'ymaps'
        }
    }
});

require(['jquery', 'formstyler'],function() {
    $(document).ready(function() {
        
        $('.arrow-down-btn').on('click', function(e) {
            e.preventDefault();
            $( this ).closest('.control-row').next().toggleClass('dn');
            $( this ).toggleClass('arrow-up-btn');
        });

        $('input:checkbox').styler();
    });

    (function(cont) {
        if (!cont.length) return;

        require(['ymaps'], function(ymaps) {
            ymaps.ready(initMap);

            function initMap() {
                var myMap = new ymaps.Map(cont.attr('id'), {
                    center: [60.153151, 30.286574],
                    zoom: 13
                });
            }
        });
    })($('#map'));
});
  • Вопрос задан
  • 523 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы