Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenLayers steals click events with Popups
    primarykey
    data
    text
    <p>Why does FramedCloud popup steal click events inside the popup?</p> <pre><code>current_popup = new OpenLayers.Popup.FramedCloud( "featurePopup", f.geometry.getBounds().getCenterLonLat(), new OpenLayers.Size(0,0), "&lt;b&gt;Наблюдения&lt;/b&gt;&lt;br/&gt;" + $.map(features, function(fe) { return fe.attributes.description; }).join('&lt;br/&gt;'), null, false, null); map.addPopup(current_popup, true); $('#map').on('click', function() { console.log('test'); return false; }); </code></pre> <p>Captures click events always except when I click a link inside a popup. The popup and the anchors are descendants of <code>#map</code>.</p> <ul> <li>Click the map => callback is fired</li> <li>Click a marker => callback is fired, popup is shown</li> <li>click inside popup (not on a link) => callback is not fired</li> <li>click a link inside a popup => same way, nothing happens</li> </ul> <p>The code in that part of OL is quite obscure.</p> <p>Why does it catch clicks inside the popup? How do I take them back?</p> <p><strong>edit</strong>: debugging deeper in OL: this function is fired:</p> <pre><code>bindAsEventListener: function(func, object) { return function(event) { return func.call(object, event || window.event); }; </code></pre> <p><code>event.target</code> is the anchor, exactly what I expect:</p> <pre><code>&lt;a class="edit-card-link" href="/form/?id=806"&gt;...&lt;/a&gt; </code></pre> <p><code>func</code> is:</p> <pre><code>handleBrowserEvent: function(evt) { var type = evt.type, listeners = this.listeners[type]; if (!listeners || listeners.length == 0) { return; } var touches = evt.touches; if (touches &amp;&amp; touches[0]) { var x = 0; var y = 0; var num = touches.length; var touch; for (var i = 0; i &lt; num; ++i) { touch = touches[i]; x += touch.clientX; y += touch.clientY; } evt.clientX = x / num; evt.clientY = y / num; } if (this.includeXY) { evt.xy = this.getMousePosition(evt); } this.triggerEvent(type, evt); } </code></pre> <p><code>this</code> is OpenLayers.Event class instance, <code>evt.target</code> is still that anchor, <code>listeners</code> contains 1 listener:</p> <pre><code>function (evt){OpenLayers.Event.stop(evt,true);} </code></pre> <p>Is this the reason? How do I take it out?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload