Search code examples
struts2-jquery

indexOf for strings not working after struts jquery plugin 3.7.1 upgrade


I upgraded struts jquery plugin to 3.7.1 and jquery-ui.js to 1.10.4. With my previous struts jquery plugin 3.1.1 and jquery-ui.js 1.8.15, indexOf for the strings is working. Dont know where it hit after upgrade. I get the following error.

SCRIPT5007: Unable to get value of the property 'indexOf': object is null or undefined

My code is as below.

var innerSpanId = $(this).attr('id');
var value = innerSpanId.indexOf('accountcheckbox');

Do give in your suggestions?


Solution

  • I was trying to get the index of strings without an object.

    In upgraded jquery use the string object.

    var innerSpanId = new String($(this).attr('id'));
    var value = innerSpanId.indexOf('accountcheckbox');
    

    Works Perfect!!!