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 pagination = (function () { | |
var TOTAL; // всего статей | |
var PER_PAGE = 3; // статей на 1-ой странице | |
var CURRENT_PAGE = 1; // текущая страница | |
var SHOW_MORE_BUTTON; | |
var SHOW_MORE_CALLBACK; // функция, которую вызывать, когда произошел клик по кнопке | |
/* | |
Total: Всего статей в ArticleModel. (Надо будет еще учесть, что total меняется при применении фильтров) | |
showMoreCb: функция, которую надо вызвать при клике на кнопку "Показать Еще" |
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
<table> | |
<tr> | |
<td> | |
<label for="agree">Согласен с правилами</label> | |
</td> | |
<td> | |
<input id="agree" type="checkbox"> | |
</td> | |
</tr> | |
<tr> |
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
<label>Кликни меня <input type="checkbox"></label> |
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
/* Получили кнопки как HTML-Element*/ | |
var button = document.getElementById('my-button'); | |
/* Функция, которую назначим обработчиком */ | |
function handleClick() { | |
console.log('Хендлю клик'); | |
} | |
/* Прикрепляем обработчика на событие 'click' */ | |
button.addEventListener('click', handleClick); |
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
<input id="my-input" type="text" value="Text"> | |
<button id="clear-button">Clear</button> | |
<p id="my-p">Text</p> |
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
<form>FORM | |
<div>DIV | |
<p>P</p> | |
</div> | |
</form> |
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
function handleEvent(event) { | |
alert(event.currentTarget); | |
event.stopPropagation(); /* Прекратить всплытие */ | |
} | |
var form = document.querySelector('form'); | |
var div = document.querySelector('div'); | |
var p = document.querySelector('p'); | |
form.addEventListener('click', handleEvent); |
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
<div class="article-list"> | |
<article>Статья №1 <button>x</button></article> | |
<article>Статья №2 <button>x</button></article> | |
<article>Статья №3 <button>x</button></article> | |
<article>Статья №4 <button>x</button></article> | |
<article>Статья №5 <button>x</button></article> | |
</div> |
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
/* Пример c делегированием */ | |
var articleListNode = document.querySelector('.article-list'); | |
articleListNode.addEventListener('click', handleDeleteBtnClick); | |
function handleDeleteBtnClick(event) { | |
/* | |
event.target это что угодно внутри .article-list, | |
надо проверить, что event.target это именно наша кнопка | |
*/ | |
if (event.target.tagName !== 'BUTTON') { |
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
<input id="my-input" type="text" value="Text"> | |
<button id="clear-button">Clear</button> | |
<p id="my-p">Text</p> | |
<input id="my-checkbox" type="checkbox"> | |
<p id="checkbox-text"></p> |