• Register
0 votes

Problem :

Facing following chrome error
error in event handler for (unknown): typeerror: cannot read property 'indexof' of undefined
6.9k points

1 Answer

0 votes

Solution :

1. No need to use a jQuery each for this. 

2. No need to alter an array that you are operating on. If you want to remove elements from an array then you can use filter. Filter has following signature:

someArray.filter(function(item, index, array) {
  // filter to return a value that is truthy to keep an item or falsey to remove it

3. Filter always returns a new array with only the values that match what you want.In your case it should look as follows:

var filteredProducts = cart_products.filter(function(item) {
  return item.indexOf(product + "^")
36.1k points

Related questions

1 vote
1 answer 83 views
Problem: I have elementary knowledge of Jquery and Javascript. Currently I am working on the pagination and I am trying to use the DataTables plugin. I have observed that on some of the tables it works as expected but on some of my tables it gives below error: " ... it is very common error but I am unable to find anything related to my problem. Kindly help me if any Jquery expert is around.
asked Jun 2 Martin K 6.6k points
0 votes
1 answer 16 views
Problem: I am unable to fix the below listed Datatables error: "SCRIPT5007: Unable to set property '_DT_CellIndex' of undefined or null reference." I have already tried to look for the solution all over the internet and but unable to find the best solution for my ... am currently unable to fix this issue. Is there anything which I am missing here? Please Note: I am very newbie with JavaScript.
asked Jul 16 Raphael Pacheco 3.2k points
0 votes
1 answer 19 views
Problem: I have fundamental knowledge in PHP. Recently I have written a php code for bootstrap collapse but I am facing the error as below: "Cannot read property 'querySelectorAll' of null." I have spent a huge amount of time to this very simple problem. If I try ... js:378) at Function.each (jquery.js:368) at jQuery.fn.init.each (jquery.js:157) at HTMLButtonElement.<anonymous> (collapse.js:374)
asked Jul 4 Raphael Pacheco 3.2k points
0 votes
1 answer 11 views
Problem: I have many movies in my website but I am unable to play movie. Please find below my code in java. I sent the name of video id to the javascript: for(int i=1; i<=Integer.parseInt(film[0][0]); i++) { nr="id"+Integer.toString(i);   ... the error: Uncaught TypeError: Cannot read property 'Play' of undefined. I am looking for java and javascript expert who can help me in fixing above error.
asked Aug 7 Raphael Pacheco 3.2k points
0 votes
2 answers 441 views
Problem : I am very new to chrome extension development. The issue which I am facing is not related to accessing the chrome:// url but I do not want to edit anything there, now the issue is regarding the execution of the chrome.tabs.executeScript() which I am using ... fine when used alone in a html file. The main aim of my extension is to provide auto complete while writing in a text field.
asked Nov 21, 2019 peterlaw 6.9k points