Rails 2.0 Breaks Javascript?

I have a Rails app frozen to v1.2.5 with a Java Script ticker that
rotates through news article headlines. It works just fine.

I am porting my app to Rails 2.0, and have implemented the Java Script
ticker EXACTLY as I did before, but now I get a Javascript error in my
browser.

I can’t think of anything that has changed to cause this problem
except for the Rails environment.

Any ideas?

P.S.
If you need to see any of my code, let me know.

We’ll need to see the javascript ticker code.

Jason

Here it is. The error occurs in the ticker.prototype.rotatemsg
function. (Exact error message is “this.items[this.pointer].attributes
has no properties” on line 44.)

// -------------------------------------------------------------------
// Main Ticker Object function
// ticker(items, tagId, delay, optionalswitch)
// -------------------------------------------------------------------

function ticker (items, tagId, delay, optionalswitch) {
this.items = eval(items); // List of things to cycle through
this.tickerId = tagId; // ID of ticker div to display information
this.delay = delay; // Delay between msg change, in miliseconds.
this.logicswitch = (typeof optionalswitch != “undefined”) ?
optionalswitch : -1;
this.mouseoverBool = 0; // Boolean to indicate whether mouse is
currently over ticker (and pause it if it is)
this.pointer = 0;
// var tickerDiv = document.getElementById(this.tickerId);
// tickerDiv.innerHTML = “Initializing ticker…”;
this.initialize();
}

// -------------------------------------------------------------------
// initialize()- Initialize ticker method.
// -Gets contents and parse it using JavaScript DOM methods
// -------------------------------------------------------------------

ticker.prototype.initialize = function () {
if (this.items.length == 0) { // if no articles found in returned
content
document.getElementById(this.tickerId).innerHTML = “Sorry, there are
no articles to display.”;
return;
}
var instanceOfTicker = this;
document.getElementById(this.tickerId).onmouseover = function ()
{instanceOfTicker.mouseoverBool = 1}
document.getElementById(this.tickerId).onmouseout = function ()
{instanceOfTicker.mouseoverBool = 0}
this.rotatemsg();
}

// -------------------------------------------------------------------
// rotatemsg()- Rotate through messages and displays them
// -------------------------------------------------------------------

ticker.prototype.rotatemsg = function () {
var instanceOfTicker = this;
if (this.mouseoverBool == 1) { //if mouse is currently over ticker,
do nothing (pause it)
setTimeout(function () {instanceOfTicker.rotatemsg()}, 100);
} else {
var tickerDiv = document.getElementById(this.tickerId);
var tickerContent = ‘’ +
this.items[this.pointer].attributes.title + ‘
’;
tickerDiv.innerHTML = tickerContent;
this.pointer = (this.pointer < this.items.length - 1) ? this.pointer

  • 1 : 0;
    setTimeout(function () {instanceOfTicker.rotatemsg()}, this.delay)
    //
    update container every second
    }
    }

Thanks for helping me ferret this out.

OK, as weird as it is, I removed “attributes” from
this.items[this.pointer].attributes.id and it works.

Thanks a ton for your time, though. I apologize for not catching this.