Trouble with invalid argument when switching jQueryUI based tabs
Here's a page with the issue
To reproduce the error, using IE - click the directions tab, then any of the others.
What I'm trying to do is this:
On page load, do nothing really. However, when the directions tab loads - setup the map. Like so:
$('#tabs').bind('tabsshow', f开发者_运维问答unction(event, ui) {
if (ui.panel.id == "tabs-5") {
// get map for directions
var dirMap = new GMap2($("div#dirMap").get(0));
dirMap.setCenter(new GLatLng(35.79648921414565,139.40663874149323), 12);
dirMap.enableScrollWheelZoom();
dirMap.addControl(new PanoMapTypeControl());
geocoder = new GClientGeocoder();
$("#dirMap").resizable({
stop: function() { dirMap.checkResize(); }
});
// clear dirText
$("div#dirMapText").html("");
dirMap.clearOverlays();
var polygon = new GPolygon([new GLatLng(35.724496338474104,139.3444061279297),new GLatLng(35.74748750802863,139.3363380432129),new GLatLng(35.75765724051559,139.34303283691406),new GLatLng(35.76545779822543,139.3418312072754),new GLatLng(35.767547103447725,139.3476676940918),new GLatLng(35.75835374997911,139.34955596923828),new GLatLng(35.755149755962755,139.3567657470703),new GLatLng(35.74679090345495,139.35796737670898),new GLatLng(35.74762682821177,139.36294555664062),new GLatLng(35.744422402303826,139.36346054077148),new GLatLng(35.74860206266584,139.36946868896484),new GLatLng(35.735644401200986,139.36843872070312),new GLatLng(35.73843117306677,139.36174392700195),new GLatLng(35.73592308277646,139.3531608581543),new GLatLng(35.72686543236113,139.35298919677734),new GLatLng(35.724496338474104,139.3444061279297)], "#f33f00", 5, 1, "#ff0000", 0.2);dirMap.addOverlay(polygon);
// load directions
directions = new GDirections(dirMap, $("div#dirMapText").get(0));
directions.load("from: Yokota@35.74005964772476,139.37083393335342 to: Ruby International@35.79648921414565,139.40663874149323");
}
});
What the heck is causing the error? The IE javascript debugger claims the error lies in main.js, line 139 character 28. (the google maps api file). Which is this line:
function zf(a,b){a=a.style;a.width=b.getWidthString();a.height=b.getHeightString()}
Any ideas? Thanks in advance!
The problem appears to be a known issue with jQuery Tabs and IE, see: Why does my slider, Google Map, sIFR etc. not work when placed in a hidden (inactive) tab?
The suggested solution is to override the jQuery Tabs CSS using:
.ui-tabs .ui-tabs-hide {
position: absolute;
left: -10000px;
}
However, this does not immediately fix your problem because if you search the CSS you will see that your .ui-tabs-hide definition contains:
.ui-tabs .ui-tabs-hide { display: none !important; }
This CSS makes the suggested fix ineffective. So to fix the problem you need to tweak the suggested fix so that it reads:
.ui-tabs .ui-tabs-hide {
display: block !important;
position: absolute;
left: -10000px;
}
This should get rid of the problem. HTH.
精彩评论