bjornd / jvectormap

jvectormap.com
GNU Affero General Public License v3.0
1.39k stars 431 forks source link

Firefox (35) and map loaded with AJAX does not work #312

Closed Lechus closed 9 years ago

Lechus commented 9 years ago

HI,

I load jvectormap div with executing JS code (var map = new jvm.Map()...) with AJAX. It works in Chrome, IE, but does not work in Firefox. If everything is loaded at once, without AJAX, it works in Firefox. There is an error in FireBug console and In Browser Console (ctrl+shift+j) there is an error:

NS_ERROR_FAILURE:  jquery-jvectormap-2.0.1.min.js:700
Lechus commented 9 years ago

Error looks similar to: https://github.com/adobe-webplatform/Snap.svg/issues/209 But I do not do any transform or append.

Looks like the div is not present/accessible before js code is executed in FF?

Lechus commented 9 years ago

In FF you need to wait before div will be accessible. Looks like a problem with FF.

andi1984 commented 9 years ago

@Lechus How did you actually fixed your problem? How do you notice whether the map container div is accessible or not?

Lechus commented 9 years ago

@andi1984 : Browsers execute code two times and on the first time div is not accessible. Only Firefox throws exception and stops working. So I added checking if div is accessible with jquery.

if (jQuery(#divmap').length >0 )

On first testing it is false, but on second it works. Hope it makes sense.