Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Layers dialog in IE7 #862

Merged
merged 1 commit into from
Aug 1, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions src/control/Control.Layers.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -133,16 +133,34 @@ L.Control.Layers = L.Control.extend({
this._separator.style.display = (overlaysPresent && baseLayersPresent ? '' : 'none'); this._separator.style.display = (overlaysPresent && baseLayersPresent ? '' : 'none');
}, },


_addItem: function (obj, onclick) { //IE7 bugs out if you create a radio dynamically, so you have to do it this hacky way
//Ref: http://stackoverflow.com/questions/118693/how-do-you-dynamically-create-a-radio-button-in-javascript-that-works-in-all-bro/119079#119079
_createRadioElement: function (name, checked) {

var radioHtml = '<input type="radio" name="' + name + '"';
if (checked) {
radioHtml += ' checked="checked"';
}
radioHtml += '/>';

var radioFragment = document.createElement('div');
radioFragment.innerHTML = radioHtml;

return radioFragment.firstChild;
},

_addItem: function (obj) {
var label = document.createElement('label'); var label = document.createElement('label');


var input = document.createElement('input'); var input;
if (!obj.overlay) { if (obj.overlay) {
input.name = 'leaflet-base-layers'; input = document.createElement('input');
input.type = obj.overlay ? 'checkbox' : 'radio';
input.defaultChecked = this._map.hasLayer(obj.layer);
} else {
input = this._createRadioElement('leaflet-bas-layers', this._map.hasLayer(obj.layer));
} }
input.type = obj.overlay ? 'checkbox' : 'radio';
input.layerId = L.Util.stamp(obj.layer); input.layerId = L.Util.stamp(obj.layer);
input.defaultChecked = this._map.hasLayer(obj.layer);


L.DomEvent.on(input, 'click', this._onInputClick, this); L.DomEvent.on(input, 'click', this._onInputClick, this);


Expand Down