[OpenLayers-Dev] The dot in the ID name difficults jQuery integration

Tim Schaub tschaub at opengeo.org
Tue Apr 17 12:08:44 EDT 2012


I agree this is something that should be addressed.  The dots in
element ids has bugged me for a long time as well.  Here's a commit
that is a first step toward correcting things:

https://github.com/tschaub/openlayers/commit/53059408084074903212abd4bf7995b3ad4fb0a6

I'll issue a pull request when I make some time to address a couple
remaining test failures.

I am curious why you'd be trying to access the dom element used to
render a feature though.  This is something I'd consider unsupported
(it won't work with the renderer abstraction in a cross-browser way).
Depending on your use case, there's likely a better way to handle
interaction or rendered feature access.

Tim

On Mon, Apr 16, 2012 at 1:33 PM, Fernando Norte
<fernando at globalgeo.com.br> wrote:
> Hi,
>
> I have been through a difficult time to integrate jQuery with OpenLayers,
> it's because I was trying to relate the elements created by OpenLayers and
> the jQuery to get values as position or to use features like Dialog (jquery
> UI) or qTIP, or other things.
>
> The problem I'd realized was in the name of the ID used by OpenLayers in web
> elements (like <div> or <svg>), there is dots in the id name, but for jQuery
> (and generaly others frameworks who threat like CSS) the dot in the ID is a
> separation, that means the class used with the ID. So, I have to create a
> scape to the dots.
>
> Some example:
>
> The openLayers create the id <circle id="OpenLayers.Geometry.Point_188">
> $("#OpenLayers.Geometry.Point_188") <- this is like search this element:
> <tag id="OpenLayers" class="Geometry Point_188">
>
> So I have to create a scape to the dot :
> $("#OpenLayers\.Geometry\.Point_188")
>
> A simple line to a var in javascript solve this problem:
> var featID = "#" + f.geometry.id.replace(/\./g,'\\.');
> $(featID);
>
> I'm noticing this and wanna know, if this is a bug or just a suggestion to
> better the software, or nothing?
> And how is the best way to report this?
>
> My regards,
>
> Fernando Norte
> Developer at http://Globalgeo.com.br
> Nova Lima - MG - Brazil
>
>
>
> _______________________________________________
> Dev mailing list
> Dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-dev
>



-- 
Tim Schaub
OpenGeo http://opengeo.org/
Expert service straight from the developers.


More information about the Dev mailing list