Skip to content

project.js initialization function #20

@alisonjo315

Description

@alisonjo315

https://github.com/CU-CommunityApps/cwd_project/blob/main/js/project.js

Let's change how project.js is initialized -- follow-up to discussion on Slack.

Specifically:

  • Use Drupal 8/9 best practices
    • Er, well now it's Drupal 10!...
  • (Probably?) Include 'use strict'; with whatever we come up with.

To do

  • Decide how to init project.js
  • Update project.js
  • Update cwd_project on CD Demo (manually)
  • (Optionally) Publish cwd_project release with this change

Background

Drupal reference

Best practices laid out in Drupal JavaScript API documentation

What's in project.js now

(https://github.com/CU-CommunityApps/cwd_project/blob/main/js/project.js)

jQuery(document).ready(function($) {// By default, site search uses this site.
  $('input[type=radio][name=sitesearch]').on('change', function() {
    switch ($(this).val()) {
      // ...etc etc etc...
    }
  });

});

What's in some of our D8 sites' child theme JS files

(probably based on the old cwd_ssit theme?? -- but I haven't confirmed this speculation)

(function ($, Drupal) {
  'use strict';// By default, site search uses this site.
  $('input[type=radio][name=sitesearch]').on('change', function() {
    switch ($(this).val()) {
      // ...etc etc etc...
    }
  });})(jQuery, this);

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions