In a project I'm working on, I need to change the href
value of a <a>
-Tag dynamically.
So I'm using something like this:
var link = '/foo' // Some calculation to determine the correct link.
$('div.button-export a').attr('href', link);
And it works in every browser except - of course - IE8.
It just ignores the .attr()
method or there is a bug or what. I need the fix this for IE8 and I need to fix it fast.
Do you have any idea what the heck is going on in IE8 and how to solve this?
UPDATE: The full code
var exportLink = jQuery('div.button-export a').first();
// TODO: SHOULD DO THIS WITH THE getExtent() METHOD
var data = {
box:[
GRD.mapController.map.extent.xmin,
GRD.mapController.map.extent.ymin,
GRD.mapController.map.extent.xmax,
GRD.mapController.map.extent.ymax
],
sr:GRD.mapController.map.extent.spatialReference.wkid,
layer:GRD.mapController.shownCountryLayer,
layerNoRegions:GRD.mapController.shownCountryLayerNoRegions,
urlRegions:encodeURIComponent(GRD.mapController.config.country),
urlCountry:encodeURIComponent(GRD.mapController.config.countryNoRegions)
};
exportLink.prop('href', Routing.generate('api_export_report_pdf', { "id":CI.report.cid, "data":JSON.stringify(data) })).show();
Update Sorry for the confusion. Of course I used the correct selector. I just changed it a little. Still doesn't work.
Finally I was able to detect the problem. There was no real bug, the parsed DOM-Tree in the developer tool of IE 8 just didn't update, so I had to refresh it manually...
Also the link did not work, because there was a button inside and IE8 seems to have problems with <button>
inside a <a>
-Tag.
Sorry for all the confusion.