ref: context value "id"

This commit is contained in:
relikd
2024-07-03 00:14:42 +02:00
parent ce33e15a59
commit cc8833037f
2 changed files with 5 additions and 4 deletions

View File

@@ -28,6 +28,7 @@ class MapLocationWidget(Widget):
def get_context(self, name, value, attrs):
context = super().get_context(name, value, attrs)
context['id'] = context['widget']['attrs']['id']
context['map_options'] = json.dumps(
context['widget']['attrs'].get('options'))
return context

View File

@@ -1,8 +1,8 @@
<div style="width: 100%">
<input name="{{ widget.name }}" id="{{ widget.attrs.id }}_value" type="hidden" value="{{ widget.value|default:'' }}" />
<div id="{{ widget.attrs.id }}_map" style="width: 100%; height: 400px"></div>
<a href="" id="{{ widget.attrs.id }}_reset">Remove</a>
<input name="{{ widget.name }}" id="{{id}}_value" type="hidden" value="{{ widget.value|default:'' }}" />
<div id="{{id}}_map" style="width: 100%; height: 400px"></div>
<a href="" id="{{id}}_btn"></a>
<script>
MapLocationInit("{{ widget.attrs.id }}", {{ map_options|safe }});
MapLocationInit("{{id}}", {{ map_options|safe }});
</script>
</div>