-
-
Save amiskov/c35a5d4d91e0108f076c0b359a189f48 to your computer and use it in GitHub Desktop.
This file contains 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
<ul class="products js-products"> | |
<li class="product"> | |
<img src="trousers.jpg" alt="" class="product__img"> | |
<button class="product__buy" data-price="120">Купить</button> | |
</li> | |
</ul> | |
<script> | |
$('.js-products').on('click', '.product__buy', function(event) { // .product__buy или .js-product-buy? | |
// Нужно ли давать класс с префиксом `js-` кнопке, если обработчик | |
// навешивается на li? Или обращаться к ней по .product__buy? | |
var price = $(this).data('price'); | |
buyProduct(price); // функционал покупки | |
}); | |
</script> |
Для поддержки, можем договориться ставить рядом с id (который используется в js) класс .js-use-id
или что-то в этом роде
Нужно ли добавлять префикс js-
для темплейтов? Например:
<script id="someTemplate" type="text/x-jsrender">
{{if name}}<p class="nearest-salon-popup__name">{{:name}}</p> {{/if}}
</script>
Он используется в JS, но это мета-информация. Никаких обработчиков нет.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Еще про айдишники надо подумать... Просто если у элемента стоит
id
, точно не ясно, используется ли он в js или это на нем якорь навешен или просто так он там стоит. А с классомjs-class-name
все понятно — используется в js.