IE8 Selecting an item in a dropdown choices list gives the error "JS error Line 717 of jquery-1.7.2.js"

Dec 6, 2012 at 10:51 AM

Hi,

I have a choices dropdown list which is working correctly in Chrome and Firefox. However, in IE 8 when I select an item in the list, the following error is displayed:

---------------------------
Message from webpage
---------------------------
Error message: Object expected
URL: http://localhost:8090/Scripts/jquery-1.7.2.js
Line Number: 717
---------------------------

The method in jQuery it is pointing to is:

inArray: function( elem, array, i ) {
		var len;

		if ( array ) {
			if ( indexOf ) {
				return indexOf.call( array, elem, i );
			}

			len = array.length;
			i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;

			for ( ; i < len; i++ ) {
				// Skip accessing in sparse arrays
				if ( i in array && array[ i ] === elem ) {
					return i;
				}
			}
		}

		return -1;
	}

This method is used in NakedObjects-Ajax.js in the method api.updateChoices.

Any ideas how to get around this?

Thanks very much,

John

Coordinator
Dec 6, 2012 at 2:04 PM

It's a bug. I'll raise a ticket and the fix should be in the next release. In the mean time, to patch, 

File NakedObjects-Ajax.js- function updateChoices

replace

if (!parmsString || ($.inArray($(this).attr('id'), parms) === -1 && $.inArray($(this).attr('id'), "-encryptedField-" + parms) === -1)) {
            // not monitoring this field so return
            api.ajaxCount--;
            return true;
        }

with

  var encParms = $.map(parms, function (item) {
            return "-encryptedField-" + item;
        });

        if (!parmsString || ($.inArray($(this).attr('id'), parms) === -1 && $.inArray($(this).attr('id'), encParms) === -1)) {
            // not monitoring this field so return
            api.ajaxCount--;
            return true;
        }

thanks for finding that - interesting that it only manifests because ie8 will not handle a string rather than array passed to inArray

Dec 6, 2012 at 2:14 PM

That fixed the problem. Thank you!