Skip to content

Instantly share code, notes, and snippets.

@kovaldn
Last active December 5, 2023 18:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save kovaldn/a31cbf5bba3da0d1ebf6 to your computer and use it in GitHub Desktop.
Save kovaldn/a31cbf5bba3da0d1ebf6 to your computer and use it in GitHub Desktop.
JS : good module
// Объявление модуля
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