Thanks Ryan and Greg, but I could not get either of your solutions to work. I have just gone back to a standard for loop for now.  I will look into this more when I’m not on such a tight deadline.

 

Thanks for the explanations it really helped.

 

 

Jon Whitcraft
Indianapolis Motor Speedway
[EMAIL PROTECTED]

Phone: (317) 492-8623 :: Fax: (317) 492-6419

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ryan Gahl
Sent: Thursday, March 16, 2006 11:02 AM
To: rails-spinoffs@lists.rubyonrails.org
Subject: RE: [Rails-spinoffs] This is driving me crazy!!!

 

You need to bind your inputs.each() iterator to “this”… otherwise “this” is not the outer object, but the function object of the iterator…

 

inputs.each( function(input) {

                                    try {

                                                if(validInputs.indexOf(input.id) != -1) {

                                                            //input.>

                                                            Event.observe(input.id,'blur',this.alertBox.bind(this),false);

                                                }

                                    } catch(e) {

                                                alert(e);

                                    }

                        }.bind(this));

 

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Whitcraft, Jon
Sent: Thursday, March 16, 2006 9:56 AM
To: rails-spinoffs@lists.rubyonrails.org
Subject: [Rails-spinoffs] This is driving me crazy!!!

 

I have the following code but it keeps on giving me this error when it runs.

 

--- Error: this.alertBox has no properties

 

What would be causing this?  My Code checks out when I call this.alertBox() from the setup function it works fine but when I try and put in on an event observer it doesn’t work.


What do you guys think?

 

Thanks,

 

Jon

 

Code Here:

 

 

var Updater = Class.create();

 

Updater.prototype = {

            initialize: function() {

                        var options = Object.extend({

                                    currentItemId: 0,

                                    debug: false

                }, arguments[0] || {});

                this.options = options;

                this.setup();

            },

            setup: function() {

                        validInputs = ['name','image','headline','caption'];

                        validInputs = $A(validInputs);

                       

                        inputs = document.getElementsByTagName('input');

                        inputs = $A(inputs);

                       

                        inputs.each( function(input) {

                                    try {

                                                if(validInputs.indexOf(input.id) != -1) {

                                                            //input.>

                                                            Event.observe(input.id,'blur',this.alertBox.bind(this),false);

                                                }

                                    } catch(e) {

                                                alert(e);

                                    }

                        });

           

            },

            alertBox: function() {

                        alert("Hello")

            }

}

 

********************

********************

This E-mail (and attachments) may contain confidential/privileged information intended only for the named addressee(s). If you are not an intended recipient, do not read, copy, disseminate or take any action based on the content of this E-mail. Please notify the sender by reply E-mail and erase this E-mail from your system. Your assistance is appreciated. E-mail transmission may not be secure or error-free. The company is not responsible for any loss/damage arising from any virus transmitted.

********************

********************

The information transmitted in this electronic mail is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material.  Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers.

_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to