Ryan,
I don't expect an answer, I just thought I'd ask. ;)  If you get time, I'll take whatever insight you can give. 

As far as the speed issue, I have been thinking about turning the Effects off by default as well as they are not really needed.  

eval() is always my enemy.  But to be honest, I am not sure how I can get away without it and have the same functionality (dynamic effects)


Thanks,
-Greg


On Feb 3, 2006, at 2:25 PM, Ryan Gahl wrote:

I apologize for this incomplete response, as I don’t have time right now to look at the script in whole, but I did check out your page. In FF 1.5 your alerts are VERY slow. Based only on your email, I’m assuming that is due in large part to your usage of the eval() statement, and that you should really try to cut that out of your code. Very rarely is that a requirement, and it does execute slower than normal code.

 

Other than that, like I said I apologize for not having more of an answer. If I get some time I’ll try to take a gander.

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Greg Militello
Sent: Friday, February 03, 2006 12:51 PM
To: [email protected]
Subject: [Rails-spinoffs] Anonymous function variable scope issue

 

Hey all,

            I joined this list mostly because I don't see too much in the OO _javascript_ arena, and I have q's (of course).

 

I have a little pet project I am working on, you can see it here:

 

            I have a class Notify.Alert() that takes some options and displays a div alert instead of a _javascript_ one.  Currently it is configurable to allow several options, including the effects for showing and hiding the divs (using script.aculo.us).  

 

            Now onto the questions.  If you look at my main _javascript_ include:

 

            You should notice the first declarations I have are:

var notifyDestination = '';

var notifyOutEffect = '';

var notifyIdPrefix = '';

 

            The only reason these exist is because of variable scope issues.  If you look at Notify.Alert.draw()  you'll see that I am using them in an anonymous function for an onClick event:

objAlertOverlay. () {eval ("new "+notifyOutEffect+ " ('"+notifyIdPrefix+"'+ 'AlertOverlay');"); return false;}

 

            What I wanted was this (using the values inside the object, not the globally defined ones):

objAlertOverlay. () {eval ("new "+this.options.notifyOutEffect+ " ('"+this.options.notifyIdPrefix+"'+ 'AlertOverlay');"); return false;}

            But IE chokes, and says it doesn't know how to implement it (FireFox/Safari work).   I think I need the eval there, or else the objAlertOverlay won't know the Effect class, etc.

 

 

            I also don't like my solution (even if it does work).  I was thinking an event listener or something may help, but honestly I don't have a clue how to implement one.  Any thoughts?  Is there an easy way to do this that I just am not seeing?

 

 

Thanks a ton, sorry if it was long winded.  Feel free to ask questions if I was not clear enough.

 

-Greg

 

PS: If you feel like giving me feedback on the script itself, I would appreciate that too.  I do not mind other peoples input.  (I have a list of todo's already)

 

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 mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to