I'd like to dynamically include/remove a property at run time.
The problem I have is, using the Flotr2 Jquery library, I'm stuck in that the legend (a property) doesn't appear to be properly supported in IE. Due to time restraints, I've got the OK to do a quick hack.
So, this is a stripped version the code I have, including my attempt
Flotr.draw(
container, myArrayForGraph, {
if (!IsThisIe()) {
legend: {
show: true,
container: legendContainer
},
}
});
As you can see, I want to call 'IsThisIe()' and if it returns false, then add the legend property.
This isn't working, I'm assuming that we can't do this when Javascript expects a property. The message is
SyntaxError: missing : after property id
I know I could create 2 different objects and have something like
if (IsThisIe())
{
Flotr.draw(
container, myArrayForGraph, {
///etc
}
else
{
Flotr.draw(
container, myArrayForGraph, {
legend:
//etc
}
But this is duplicating code, each object has many properties.
So, is there a way to not include properties in the manner I've described or am I stuck with having to manage the code in multiple places??
Try:
Then find out why IE doesn't like your code - start with the error console ;)
I have found the bug. It's a part of the code Flotr functions. Find where
Flotr.DOM.node
is defined, and replace it with this:IE doesn't like it if you nuke the
innerHTML
of an element containing other elements that you are referring to. This fix prevents that issue.