I'm pretty new to both JavaScript and Prototype, but have been programming for over 30 years, and so this one is causing me to tear out what little hair I have left. Basically, I can't seem to figure out what is wrong when I move a function that works outside of a class into a class, it is a very simple function, just wrap a piece of text in double-quotes. But when called from within a class, the script blows up and dies. I'm using Firefox, Firebug does see that the class has the item and that it is a function; but the script dies as if it could not find the function. The JavaScript console remains empty.
Why does the function "quotes" (within the class) fail when the exact same function "dquote" (outside the class) works fine. I figure it's something simple but it has eluded me. <html> <head> <script src="../prototype.js" type="text/javascript"></script> </head> <body> <script type="text/javascript"> var printp = function( strStr ) { document.write( "<p>" + strStr + "</p>" ); }; var dquote = function( strStr ) { return "\"" + strStr + "\""; }; printp( "Begin Test!" ); printp( "Test 1: " + dquote( 'test 1' ) ); var Test_01 = Class.create( { initialize: function( strName ) { this.name = String( strName ); }, quotes: function( strStr ) { return "\"" + strStr + "\""; }, doc_name: function() { return quotes( this.name ); } }); var test_02 = new Test_01( 'test' ); printp( "Test 2: \"" + test_02.name + "\"" ); printp( "Test 3: " + test_02.doc_name() ); printp( "End Test!" ); </script> </body> </html> -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.