I wonder how to attach a library to a specific block. I do this:
in mytheme.libraries.yml
lib-name-script:
js:
header: true
js/masonry.pkgd.min.js: {}
js/main.js: {}
dependencies:
- core/jquery
in main.js
jQuery(document).ready(function() {
$('.grid').masonry({
itemSelector: '.grid-item',
columnWidth: 220,
horizontalOrder: true
});
});
and in views-view--block-some.html.twig
{{ attach_library('theme_name/lib-name-script') }}
<div class="grid">
{{ rows }}
</div>
But from some reason this dont works. :S
On the and of file I have:
<script src="/themes/theme_name/js/masonry.pkgd.min.js?oxcmsf"></script>
<script src="/themes/theme_name/js/main.js?oxcmsf"></script>
Was I corect load js, or mistake is on some other place?