templates: adjust evaluation stars templates to work in blocks (#74793) #387

Merged
fpeters merged 1 commits from wip/74793-evaluation-stars-in-blocks into main 2023-09-15 16:56:37 +02:00
2 changed files with 5 additions and 4 deletions

View File

@ -19,7 +19,7 @@
<script>
$(function() {
var $widget = $('#form_label_{{widget.name}}').parents('div.widget');
var $widget = $('[name="{{widget.name}}"]').parents('div.widget');
$widget.find('.star-choice input').on('change', function() {
if ($(this).is(':checked')) {
$(this).parent().nextAll().find('.star').removeClass('selected');

View File

@ -16,7 +16,8 @@
</div>
<script>
$(function() {
$('#form_{{widget.name}}').parent().find('.star-choice span').on('click', function() {
var $widget = $('[name="{{widget.name}}"]');
$widget.parent().find('.star-choice span').on('click', function() {
if ($(this).hasClass('selected')) {
$(this).nextAll().removeClass('selected');
} else {
@ -24,9 +25,9 @@
$(this).addClass('selected');
$(this).nextAll().removeClass('selected');
}
$('#form_{{widget.name}} option[data-index=' + $(this).data('index') + ']').prop('selected', true);
$widget.find('option[data-index=' + $(this).data('index') + ']').prop('selected', true);
});
$('#form_{{widget.name}}').parent().find('.star-choice [data-index=' + $('#form_{{widget.name}} option:selected').data('index') + ']').trigger('click');
$widget.parent().find('.star-choice [data-index=' + $widget.find('option:selected').data('index') + ']').trigger('click');
});
</script>
{% endblock %}