Fix for weird button toggles (it was a doozy!)

- Turning off autocomplete seems to have done the job
- https://stackoverflow.com/questions/36546775/html-checkboxes-keep-checked-after-refresh#36547079
This commit is contained in:
Oliver Walters 2020-09-13 17:47:40 +10:00
parent 65bc23a516
commit aa35c787b2
2 changed files with 2 additions and 48 deletions

View File

@ -218,14 +218,13 @@
{{ block.super }} {{ block.super }}
$(".slidey").change(function() { $(".slidey").change(function() {
var field = $(this).attr('field'); var field = $(this).attr('fieldname');
var checked = $(this).prop('checked'); var checked = $(this).prop('checked');
var data = {}; var data = {};
data[field] = checked; data[field] = checked;
// Update the particular field // Update the particular field
inventreePut("{% url 'api-part-detail' part.id %}", inventreePut("{% url 'api-part-detail' part.id %}",
data, data,
@ -236,49 +235,4 @@
); );
}); });
$('#activate-part').click(function() {
showQuestionDialog(
'Activate Part?',
'Are you sure you wish to reactivate {{ part.full_name }}?',
{
accept_text: 'Activate',
accept: function() {
inventreePut(
"{% url 'api-part-detail' part.id %}",
{
active: true,
},
{
method: 'PATCH',
reloadOnSuccess: true,
}
);
}
},
);
});
$('#deactivate-part').click(function() {
showQuestionDialog(
'Deactivate Part?',
`Are you sure you wish to deactivate {{ part.full_name }}?<br>
`,
{
accept_text: 'Deactivate',
accept: function() {
inventreePut(
"{% url 'api-part-detail' part.id %}",
{
active: false,
},
{
method: 'PATCH',
reloadOnSuccess: true,
}
);
}
}
);
});
{% endblock %} {% endblock %}

View File

@ -1,3 +1,3 @@
<div> <div>
<input field='{{ field }}' class='slidey' type="checkbox" data-offstyle='warning' data-onstyle="success" data-size='small' data-toggle="toggle" {% if disabled %}disabled="disabled" {% endif %}{% if state %}checked="checked"{% endif %}> <input fieldname='{{ field }}' class='slidey' type="checkbox" data-offstyle='warning' data-onstyle="success" data-size='small' data-toggle="toggle" {% if disabled %}disabled {% endif %}{% if state %}checked=""{% endif %} autocomplete="off">
</div> </div>