Page 1 of 1

Javascript error

Posted: Tue Jan 14, 2014 10:03 am
by kgb2013
Hello.

I get an error in :

Code: Select all

StiMvcViewer.prototype.showReportPage = function (htmlText, jsObject) {
   ...
   for (var num in pagesArray) {
      ...
      else if (pagesArray[num].indexOf("bookmarks") == 0) {...}                            <---- Here.
   }
}
Error description:

Code: Select all

Uncaught TypeError: Object function (deleteValue) {
		for (var o = 0; o < this.length; o++) {
			if (this[o] == deleteValue) {
				this.splice(o, 1);
				o--;
			}
		}
		return this;
	} has no method 'indexOf' 
This is because I have extended the JS Array like so:

Code: Select all

	// Calling myArray.clean(a), will remove all 'a' values from the array.
	Array.prototype.clean = function (deleteValue) {
		for (var o = 0; o < this.length; o++) {
			if (this[o] == deleteValue) {
				this.splice(o, 1);
				o--;
			}
		}
		return this;
	};
This is a standard way of extending objects in javascript as far as I know. And this is causing problems in your JS code.

Could you please change your loop over the array from this:

Code: Select all

for (var num in pagesArray)
to this? :

Code: Select all

for (var num=0; i<pagesArray.length; i++)
The current code enumerates the object properties, inluding my clean() function.
See here: http://stackoverflow.com/questions/5005 ... a-bad-idea
Perhaps, there are more than one loops that need to be changed however.

Thanks.

Re: Javascript error

Posted: Wed Jan 15, 2014 12:01 pm
by HighAley
Hello.

We have made an improvement. The patch will be available in our next prerelease build on January 17.

Thank you.

Re: Javascript error

Posted: Wed Jan 15, 2014 3:57 pm
by kgb2013
Thanks! :)

Re: Javascript error

Posted: Fri Jan 17, 2014 7:34 am
by Andrew
Hello,

We are glad to help you!