Map widget ids (again...), formsets and JS errors...

6 views
Skip to first unread message

Roberto Maurizzi

unread,
Aug 13, 2013, 1:28:54 AM8/13/13
to olwi...@googlegroups.com
Hello,

while creating a formset containing maps, I found a problem related to how the single map objects DOM ids are created.
In a django formset the various subform elements are called something like id_form-0-title or in my case id_form-0-Location (see https://docs.djangoproject.com/en/dev/topics/forms/formsets/ ).

This in turn make OLWidget create JS objects with instructions like 

var olwidget_id_form-0-Location = new olwidget.Map("id_form-0-Location", [...

Needless to say, Javascript takes the variable name as olwidget_id_form - 0 - Location and throws an error.

I have no idea how these ids are passed to the Map.render function (In my post about Map Legends I had the opposite problem: in a standalone map, outside of a form, I would always get a random id) but I suspect that field forms get their ids passed to OLWidget while normal maps outside form do not.

But unless I'm doing something wrong with the formset preparation and the related fieldnames (it's my second attempt at using one and the first including MapFields) I think there's a need to sanitize the 'id' we get from the template so that it's JS compatible.

What do you think?


Roberto

Reply all
Reply to author
Forward
0 new messages