Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Use standard form submission rather than window.location

Damian Legawiecc93737ed87fe
diff --git a/frontend/app/assets/javascripts/spree/frontend/currency.js b/frontend/app/assets/javascripts/spree/frontend/currency.js
index 1da2f6bf35..21cae8160f 100644
--- a/frontend/app/assets/javascripts/spree/frontend/currency.js
+++ b/frontend/app/assets/javascripts/spree/frontend/currency.js
@@ -1,11 +1,13 @@
Spree.ready(function ($) {
- var currencySelect = $('#currency-select select')
+ var currencySelectForm = $('#currency-select')
+ var currencySelectDropdown = currencySelectForm.find('select#switch_to_currency')
- if (currencySelect.length) {
- currencySelect.on('change', function () {
- currencySelect.attr('disabled')
+ if (currencySelectForm.length && currencySelectDropdown.length) {
+ currencySelectDropdown.on('change', function () {
+ Spree.clearCache()
+ currencySelectDropdown.attr('disabled')
Spree.showProgressBar()
- window.location = Spree.routes.set_currency(this.value)
+ currencySelectForm.submit()
})
}
})
diff --git a/frontend/app/assets/javascripts/spree/frontend/locale.js b/frontend/app/assets/javascripts/spree/frontend/locale.js
index ec8abd9864..810ff6b1ad 100644
--- a/frontend/app/assets/javascripts/spree/frontend/locale.js
+++ b/frontend/app/assets/javascripts/spree/frontend/locale.js
@@ -1,12 +1,12 @@
Spree.ready(function ($) {
- var localeSelect = $('#locale-select select')
+ var localeSelectForm = $('#locale-select')
+ var localeSelectDropdown = localeSelectForm.find('select#switch_to_locale')
- if (localeSelect.length) {
- localeSelect.on('change', function () {
- localeSelect.attr('disabled')
+ if (localeSelectForm.length && localeSelectDropdown.length) {
+ localeSelectDropdown.on('change', function () {
+ localeSelectDropdown.attr('disabled')
Spree.showProgressBar()
- Spree.clearCache()
- window.location = Spree.routes.set_locale(this.value)
+ localeSelectForm.submit()
})
}
})