From: Jeff Davis Date: Wed, 7 Jan 2015 21:12:06 +0000 (-0800) Subject: Use jQuery.noConflict to avoid conflict with other libraries X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=b63fc3d5ab54b0e1d491731e06c34535a3861778;p=contrib%2Foverdrive-eg-opac.git Use jQuery.noConflict to avoid conflict with other libraries jQuery's use of '$' as an alias was conflicting with Dojo's use of '$' as a function name on the TPAC advanced search page. We can resolve this by making OD API depend on a wrapper function that invokes jquery.noConflict(). There's an "official" way to do this using the require.js map config, but the approach we're using here is simpler (and actually works!). Signed-off-by: Jeff Davis --- diff --git a/src/jquery-noconflict.coffee b/src/jquery-noconflict.coffee new file mode 100644 index 0000000..a5aae86 --- /dev/null +++ b/src/jquery-noconflict.coffee @@ -0,0 +1,5 @@ +define [ + 'jquery' +], (jq) -> + + return jq.noConflict( true ); diff --git a/src/od_action.coffee b/src/od_action.coffee index b0441b8..cbd2537 100644 --- a/src/od_action.coffee +++ b/src/od_action.coffee @@ -2,7 +2,7 @@ # probably because it needs to be done asynchronously using setTimeout # define [ - 'jquery' + 'jquery-noconflict' 'lodash' 'json' 'od_api' diff --git a/src/od_api.coffee b/src/od_api.coffee index 9a9f88b..d29f717 100644 --- a/src/od_api.coffee +++ b/src/od_api.coffee @@ -1,5 +1,5 @@ define [ - 'jquery' + 'jquery-noconflict' 'lodash' 'json' 'cookies' diff --git a/src/od_pages_myopac.coffee b/src/od_pages_myopac.coffee index 40a27ec..4e7c7d4 100644 --- a/src/od_pages_myopac.coffee +++ b/src/od_pages_myopac.coffee @@ -2,7 +2,7 @@ # None of the extensions directly use the API, but they depend on od_action which does. define [ - 'jquery' + 'jquery-noconflict' 'lodash' 'od_config' 'jquery-ui' diff --git a/src/od_pages_opac.coffee b/src/od_pages_opac.coffee index ebd47cb..9a45122 100644 --- a/src/od_pages_opac.coffee +++ b/src/od_pages_opac.coffee @@ -2,7 +2,7 @@ # None of the extensions directly use the API, but they depend on od_action which does. define [ - 'jquery' + 'jquery-noconflict' 'lodash' 'od_api' 'od_config' diff --git a/src/overdrive.coffee b/src/overdrive.coffee index ee6d234..28bc815 100644 --- a/src/overdrive.coffee +++ b/src/overdrive.coffee @@ -11,7 +11,7 @@ # od.$.on 'od.metadata', (ev, reply) -> # do something with reply require [ - 'jquery' + 'jquery-noconflict' 'lodash' 'cookies' 'od_api'