Last active
December 5, 2023 18:51
-
-
Save kovaldn/a31cbf5bba3da0d1ebf6 to your computer and use it in GitHub Desktop.
JS : good module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Объявление модуля | |
var myModule = (function () { | |
// Инициализирует наш модуль | |
function init () { | |
_setUpListners(); | |
}; | |
// Прослушивает события | |
function _setUpListners () { | |
$('#id').on('click', _doSome); | |
}; | |
// Функция, обрабатывающая событие | |
function _doSome (e) { | |
e.preventDefault(); | |
}; | |
// Возвращаем объект (публичные методы) | |
return { | |
init: init | |
}; | |
})(); | |
// Вызов модуля | |
myModule.init(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment