Loading README.md +4 −4 Original line number Diff line number Diff line Loading @@ -151,8 +151,8 @@ Any and all combinations of defining libraries and CSS/JS should work. In Drupal, JavaScript that binds behavior to elements is supposed to do so inside a behavior attachment, using the context passed to it, and is then even expected to use the jQuery.once plugin to prevent common problems like double binding event handlers. expected to use the once plugin to prevent common problems like double binding event handlers. This can become quite monotonous, so as an alternative to using `<script>` to define global JS, you can instead provide `<script data-type"attach">` and Loading Loading @@ -201,8 +201,8 @@ as well as `data-sfc-unique-id`, which is a string that is unique to this render of the component. Drupal Core has recently started moving away from jQuery, so if you'd like to use vanilla JS with your attachments (wrapping them in "once()" instead of "jQuery.once()") you can add the "data-vanilla" attribute to your script tag. use vanilla JS with your attachments you can add the "data-vanilla" attribute to your script tag. Note that when using vanilla JS, "element" refers to your current element, not "this". For example: Loading modules/sfc_dev/js/sfc_dev.js +1 −1 Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ */ Drupal.behaviors.sfcDevPollChanges = { attach: function (context, settings) { $(window).once('sfc-dev-poll-changes').each(function () { $(once('sfc-dev-poll-changes', 'body')).each(function () { setInterval(function () { var $checkbox = $('.js-component-auto-preview'); if (!$checkbox.length) { Loading modules/sfc_dev/sfc_dev.info.yml +1 −2 Original line number Diff line number Diff line name: Single File Components Development Tools type: module description: Contains useful development tools for SFC. Do not enable in production. core: 8.x core_version_requirement: ^8 || ^9 || ^10 core_version_requirement: ^9 || ^10 dependencies: - sfc:sfc modules/sfc_dev/sfc_dev.libraries.yml +1 −1 Original line number Diff line number Diff line Loading @@ -4,4 +4,4 @@ main: js/sfc_dev.js: {} dependencies: - core/drupal.ajax - core/jquery.once - core/once modules/sfc_dev/src/Plugin/SingleFileComponent/ComponentPreview.php +1 −1 Original line number Diff line number Diff line Loading @@ -262,7 +262,7 @@ JS; $plugin_id, $plugin_definition, static::getDebugParameter($container), $container->get('app.root'), $container->getParameter('app.root'), $container->get('file_system'), $container->get('form_builder') ); Loading Loading
README.md +4 −4 Original line number Diff line number Diff line Loading @@ -151,8 +151,8 @@ Any and all combinations of defining libraries and CSS/JS should work. In Drupal, JavaScript that binds behavior to elements is supposed to do so inside a behavior attachment, using the context passed to it, and is then even expected to use the jQuery.once plugin to prevent common problems like double binding event handlers. expected to use the once plugin to prevent common problems like double binding event handlers. This can become quite monotonous, so as an alternative to using `<script>` to define global JS, you can instead provide `<script data-type"attach">` and Loading Loading @@ -201,8 +201,8 @@ as well as `data-sfc-unique-id`, which is a string that is unique to this render of the component. Drupal Core has recently started moving away from jQuery, so if you'd like to use vanilla JS with your attachments (wrapping them in "once()" instead of "jQuery.once()") you can add the "data-vanilla" attribute to your script tag. use vanilla JS with your attachments you can add the "data-vanilla" attribute to your script tag. Note that when using vanilla JS, "element" refers to your current element, not "this". For example: Loading
modules/sfc_dev/js/sfc_dev.js +1 −1 Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ */ Drupal.behaviors.sfcDevPollChanges = { attach: function (context, settings) { $(window).once('sfc-dev-poll-changes').each(function () { $(once('sfc-dev-poll-changes', 'body')).each(function () { setInterval(function () { var $checkbox = $('.js-component-auto-preview'); if (!$checkbox.length) { Loading
modules/sfc_dev/sfc_dev.info.yml +1 −2 Original line number Diff line number Diff line name: Single File Components Development Tools type: module description: Contains useful development tools for SFC. Do not enable in production. core: 8.x core_version_requirement: ^8 || ^9 || ^10 core_version_requirement: ^9 || ^10 dependencies: - sfc:sfc
modules/sfc_dev/sfc_dev.libraries.yml +1 −1 Original line number Diff line number Diff line Loading @@ -4,4 +4,4 @@ main: js/sfc_dev.js: {} dependencies: - core/drupal.ajax - core/jquery.once - core/once
modules/sfc_dev/src/Plugin/SingleFileComponent/ComponentPreview.php +1 −1 Original line number Diff line number Diff line Loading @@ -262,7 +262,7 @@ JS; $plugin_id, $plugin_definition, static::getDebugParameter($container), $container->get('app.root'), $container->getParameter('app.root'), $container->get('file_system'), $container->get('form_builder') ); Loading