Set unique map id per page in map_list
This words around the issue where a map is displayed twice while loading more maps in the home page because while loading maps some have been updated
This commit is contained in:
parent
7d9ae731c0
commit
95a16b2aaf
4 changed files with 8 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
|||
{% load umap_tags %}
|
||||
<div id="{{ prefix }}{{ map.pk }}" class="map_fragment"></div>
|
||||
<div id="{{ unique_id }}" class="map_fragment"></div>
|
||||
<script type="text/javascript">
|
||||
new L.U.Map("{{ prefix }}{{ map.pk }}", {{ map_settings|notag|safe }});
|
||||
new L.U.Map("{{ unique_id }}", {{ map_settings|notag|safe }});
|
||||
</script>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
{% for map_inst in maps %}
|
||||
<hr />
|
||||
<div class="col wide">
|
||||
{% map_fragment map_inst prefix=prefix %}
|
||||
{% map_fragment map_inst prefix=prefix page=request.GET.p %}
|
||||
<div class="legend"><a href="{{ map_inst.get_absolute_url }}">{{ map_inst.name }}</a>{% if map_inst.owner %} <em>{% trans "by" %} <a href="{% url 'user_maps' map_inst.owner.username %}">{{ map_inst.owner }}</a></em>{% endif %}</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<div class="wrapper">
|
||||
<div class="map_list row">
|
||||
{% if maps %}
|
||||
{% include "umap/map_list.html" with prefix='search_map_' %}
|
||||
{% include "umap/map_list.html" with prefix='search_map' %}
|
||||
{% else %}
|
||||
{% trans "Not map found." %}
|
||||
{% endif %}
|
||||
|
|
|
@ -50,11 +50,13 @@ def map_fragment(map_instance, **kwargs):
|
|||
'slideshow': {}
|
||||
})
|
||||
map_settings['properties'].update(kwargs)
|
||||
prefix = kwargs.pop('prefix', None) or 'map_'
|
||||
prefix = kwargs.pop('prefix', None) or 'map'
|
||||
page = kwargs.pop('page', None) or ''
|
||||
unique_id = prefix + str(page) + "_" + str(map_instance.pk)
|
||||
return {
|
||||
"map_settings": json.dumps(map_settings),
|
||||
"map": map_instance,
|
||||
"prefix": prefix
|
||||
"unique_id": unique_id
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue