Skip to content

Commit

Permalink
Add jQuery and expose on window
Browse files Browse the repository at this point in the history
`MOJFrontend` requires this to initialise the Multi select component

There's [an issue in moj-frontend](ministryofjustice/moj-frontend#134) to remove the jQuery dependency, but it's dependent on unit tests
  • Loading branch information
gregtyler committed Jun 14, 2021
1 parent 5c5d7af commit f1cfa40
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"dependencies": {
"@ministryofjustice/frontend": "0.2.4",
"cypress": "7.4.0",
"govuk-frontend": "^3.9.0"
"govuk-frontend": "^3.9.0",
"jquery": "^3.6.0"
},
"devDependencies": {
"@babel/core": "^7.11.6",
Expand Down
4 changes: 4 additions & 0 deletions web/assets/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import $ from 'jquery';
import MOJFrontend from '@ministryofjustice/frontend/moj/all.js';
import GOVUKFrontend from 'govuk-frontend/govuk/all.js';
import './main.scss';
Expand Down Expand Up @@ -76,6 +77,9 @@ function initFilterHeadings() {
}
}

// Expose jQuery on window so MOJFrontend can use it
window.$ = $;

// we aren't using the JS tabs, but they try to initialise this will stop them breaking
GOVUKFrontend.Tabs.prototype.setup = () => { };

Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3293,6 +3293,11 @@ isstream@~0.1.2:
resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"
integrity sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=

jquery@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.6.0.tgz#c72a09f15c1bdce142f49dbf1170bdf8adac2470"
integrity sha512-JVzAR/AjBvVt2BmYhxRCSYysDsPcssdmTFnzyLEts9qNwmjmu4JTAMYubEfwVOSwpQ1I1sKKFcxhZCI2buerfw==

js-tokens@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
Expand Down

0 comments on commit f1cfa40

Please sign in to comment.