#27055: Model form with geometry widgets has invalid html
-------------------------------------+-------------------------------------
Reporter: Antonis | Owner: Antonis
Christofides | Christofides
Type: Bug | Status: assigned
Component: GIS | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Antonis Christofides):
Another problem is that the contents of the <style> element are enclosed
in {% block map_css %}. Apparently this block is not redefined anywhere
else in django, but it might be redefined in third-party apps. I guess we
don't want to break such apps.
Here's a solution I've thought (completely untested): We change the
<style> element and make it an undisplayed <div> instead:
{{{#!django
<div id="map_css" style="display: none;">
{% block map_css %}
[The part inside the block we leave unchanged.]
{% endblock %}
</div>
}}}
And then we add this JavaScript:
{{{
#!javascript
var map_css = document.getElementById('map_css').innerHTML;
var style_element = document.createElement('style');
style_element.type = 'text/css';
if(style_element.styleSheet) {
style_element.styleSheet.cssText = map_css;
} else {
style_element.appendChild(document.createTextNode(map_css));
}
document.getElementsByTagName('head')[0].appendChild(style_element);
}}}
It's a bit hacky, particularly the fake <div> which only serves for
JavaScript to grab its contents with .innerHTML; but I can't find any
other way to do it since there's no cross-browser way to have a JavaScript
multiline string.
--
Ticket URL: <https://code.djangoproject.com/ticket/27055#comment:7>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/064.4a54d44dc90429ba8352509da1e59b73%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.