Manixman
Manixman

Reputation: 307

Variable causing append to not work correctly

In IE9 compatibility view off and in other major browsers (chrome, firefox, safari and opera) it appends a table row underneath when I click on the Add Question Button.

But if I turn on compatibility view in IE, it appends a blank into table below.

Now what I have realised is that if I remove this line of code below:

var flag = true;

Then it works with compatibility view in IE, but I will get an error in error console stating flag is undefined.

So how can I fix it so that I get no error in console but that its able to append table rows into the table in IE compatibility on?

Code is below:

var flag = true;

if(flag == true)
{
    var tbl_qanda = $("#qandatbl").width();
    $("#qandatbl").css({"width": (tbl_qanda - 16)+ "px"});
}

var tbl_qanda_onthefly = $("#qandatbl_onthefly").width();

if(tbl_qanda > tbl_qanda_onthefly)
{
     $("#qandatbl").css({"width": (tbl_qanda_onthefly - 16)+ "px"});
     $("#qandatbl_onthefly_container").css({"width": (tbl_qanda_onthefly)+ "px"});
}

UPDATE:

Here is jsfiddle to show you code: http://jsfiddle.net/7GjYK/

To see working version, To see what is happening please use this link DEMO and open it up in IE9 compatibility off or in any other major browser and you see that when you click Add Question, it appends a table row underneath, but if you change the compatibility view on and do same thing, it shows a blank append.

Upvotes: 0

Views: 102

Answers (1)

user2048994
user2048994

Reputation: 270

Why don't you just keep it IE9 by disabling the compatibility:

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

Upvotes: 1

Related Questions