0

Using jQuery 1.9.1 & IE8, but the page also needs to work in IE7. In code before the part that is causing the issue, I read some data in & build an array that is a SELECT statement. In the section of code where I have an issue, I am doing the following:

var found = $.map( mySelArr, function(val) {
   return val.mySelID === zSelID ? val.mySelStatement: null;
   });

I then reference it:

var selStmt = found[0];  

(there will be only 1 returned, and I know it will be in the array).

In IE7, I saw that it is throwing an exception inside jquery.js. When I step through debug on it, I see that the found length is zero (in IE7). If I change the mode to IE8, everything works fine. But in IE7, nothing gets put into the found variable.

What am I doing wrong to not be able to get this array value out in IE7? Would appreciate any thoughts.

EDIT

mySelArr is an array of Select statements, similar to:

1,<select name='mySelID_1' id='plist' ><option selected='selected' disabled='disabled' value='0'>Select Action</option><option value="1">This one</option><option value="2">That one</option></select>

and so on.

EDIT 2

I may have stumbled on the issue.

The array that held the select statements was being populated correctly in IE8, but not in IE7.

I actually had 2 arrays, one being just a number, and the other being that same number + the Select statement. The array that had the index & select statement was built using:

arr1.push({ fld1:data1, fld2:selstmt})

The one with just numbers was built using:

arr2.push(arrndx)

The arr2 was the outer FOR, the arr1 was the inner FOR. I had been referring to the number index by using:

var z = arr2[x][0];

to get the number & then using that to loop thru arr1 to get everything matching it & building the Select statement. What I discovered was that IE7 was returning undefined in the line of code above, while IE8 was returning the number (Firefox also).

I changed 2 lines of code to fix the issue:

FROM   arr2.push(arrndx) 
TO     arr2.push( {arrindex: arrndx} );

and

FROM   arr2[x][0]
TO     arr2[x].arrindex

and it works in both IE7 & IE8. IE7 didn't have a problem creating that array, or reading it - it just wasn't valid data in it because of how I attempted to reference the fields in it.

I'm not exactly sure why IE7 had a problem with it & IE8 didn't, but.... Also, the fix didn't appear to break anything else.

9
  • 2
    When I try to run this to create a test case, I get Unexpected token : because of this part: val:mySelStatement: null; You can only have one "else" in the ternary operator.
    – Jason P
    Oct 3, 2013 at 18:01
  • see edited problem for example of contents of mySelArr. @JasonP - I tried that, but it's not returning anything either.
    – steve_o
    Oct 3, 2013 at 18:04
  • Did you mean to write return val.mySelID === zSelID ? val.mySelStatement: null; Oct 3, 2013 at 18:06
  • so you have a property named mySelID which is not in that example you gave? SHouldn't val:mySelStatement be val.mySelStatement. Your question is missing a lot of context, makes it hard to give you answer. Oct 3, 2013 at 18:07
  • 1
    For the record, there are a LOT of things that work in IE8 that don't in IE7. I spent LOADS of time getting clone() to work.
    – CodeChimp
    Oct 3, 2013 at 20:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.