Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Use id to determine switch form and input

Anna Siwik86974b1dfce2
diff --git a/saleor/static/dashboard/js/components/misc.js b/saleor/static/dashboard/js/components/misc.js
index f42a241cf6..5eb8b12182 100644
--- a/saleor/static/dashboard/js/components/misc.js
+++ b/saleor/static/dashboard/js/components/misc.js
@@ -20,8 +20,8 @@ export default $(document).ready((e) => {
});
$('#product-is-published').on('click', (e) => {
- const form = $(e.currentTarget).closest('form');
- const input = form.find('input')[0];
+ const form = $(e.currentTarget).closest('#toggle-publish-form');
+ const input = form.find('#toggle-publish-switch')[0];
if (e.target === input) {
const url = form.attr('action');
fetch(url, {
diff --git a/templates/dashboard/product/detail.html b/templates/dashboard/product/detail.html
index 761083f285..1287d13183 100644
--- a/templates/dashboard/product/detail.html
+++ b/templates/dashboard/product/detail.html
@@ -162,10 +162,10 @@
<div class="col s12">
<div class="card">
<div class="card-content">
- <form action="{% url 'dashboard:product-publish' product.pk %}">
+ <form id="toggle-publish-form" action="{% url 'dashboard:product-publish' product.pk %}">
<div class="switch" id="product-is-published">
<label>
- <input type="checkbox" {% if product.is_published %} checked {% endif %}>
+ <input id="toggle-publish-switch" type="checkbox" {% if product.is_published %} checked {% endif %}>
<span class="lever"></span>
<span class="label">
{% if product.is_published %}