I think I am experiencing the variable scope problem with evalScripts. I have this block of code being returned from an Ajax.Updater call, as shown by FireBug or one of those other Firefox plugins. I have tried to boil it down to the minimum code. <script type="text/javascript"> test = function() { alert("test"); }; </script> <table class="small_input" id="edit_table_279"> --SNIP-- </table> <input type="button" onclick="test();" value="test" /> Clicking the "test" button pops a "test is not defined" error. This is basically the same code that is in the example at http:// www.sergiopereira.com/articles/prototype.js.html so I don''t know what I''m doing wrong. Here is how I call Ajax.Updater: new Ajax.Updater(updateDiv, "Profile/update.aspx", { asynchronous: true, parameters: params, evalScripts: true, onComplete: function() { refresh_columns(); } }); Yes, I am stuck in ASP.NET for this project. :-( -- Brad Ediger 866-EDIGERS _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
I just got done debugging my evalScripts calls and the test = function() style JS did not work in IE. I had to simplify it to: <script type="text/javascript">alert("test");</script> That method worked in IE and FF.> Yes, I am stuck in ASP.NET for this project.My sympathies are with you. :0 -Daniel Elmore -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Brad Ediger Sent: Tuesday, April 18, 2006 3:58 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails-spinoffs] [Prototype] evalScripts not working for me I think I am experiencing the variable scope problem with evalScripts. I have this block of code being returned from an Ajax.Updater call, as shown by FireBug or one of those other Firefox plugins. I have tried to boil it down to the minimum code. <script type="text/javascript"> test = function() { alert("test"); }; </script> <table class="small_input" id="edit_table_279"> --SNIP-- </table> <input type="button" onclick="test();" value="test" /> Clicking the "test" button pops a "test is not defined" error. This is basically the same code that is in the example at http://www.sergiopereira.com/articles/prototype.js.html so I don''t know what I''m doing wrong. Here is how I call Ajax.Updater: new Ajax.Updater(updateDiv, "Profile/update.aspx", { asynchronous: true, parameters: params, evalScripts: true, onComplete: function() { refresh_columns(); } }); Yes, I am stuck in ASP.NET for this project. :-( -- Brad Ediger 866-EDIGERS
On Apr 18, 2006, at 4:05 PM, Daniel Elmore wrote:> I just got done debugging my evalScripts calls and the test = > function() > style JS did not work in IE. I had to simplify it to: > > <script type="text/javascript">alert("test");</script> > > That method worked in IE and FF. >I''m working in FF for right now. Incidentally, I tried the above code before and it didn''t work. It''s like the scripts aren''t being evaluated at all. I have one more block of code above that script block, so in effect two script blocks must be evaluated. It looks like the first one is being evaluated, but I''m not sure.> -----Original Message----- > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of > Brad > Ediger > Sent: Tuesday, April 18, 2006 3:58 PM > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: [Rails-spinoffs] [Prototype] evalScripts not working for me > > I think I am experiencing the variable scope problem with evalScripts. > > I have this block of code being returned from an Ajax.Updater call, > as shown > by FireBug or one of those other Firefox plugins. I have tried to > boil it > down to the minimum code. > > <script type="text/javascript"> > test = function() { alert("test"); }; > </script> > > <table class="small_input" id="edit_table_279"> > --SNIP-- > </table> > > <input type="button" onclick="test();" value="test" /> > > Clicking the "test" button pops a "test is not defined" error. This is > basically the same code that is in the example > at http://www.sergiopereira.com/articles/prototype.js.html so I > don''t know > what I''m doing wrong. > > Here is how I call Ajax.Updater: > > new Ajax.Updater(updateDiv, "Profile/update.aspx", { > asynchronous: true, > parameters: params, > evalScripts: true, > onComplete: function() { refresh_columns(); } > }); > > Yes, I am stuck in ASP.NET for this project. :-( > -- > Brad Ediger > 866-EDIGERS > > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
>> > I''m working in FF for right now. Incidentally, I tried the above > code before and it didn''t work. It''s like the scripts aren''t being > evaluated at all. > > I have one more block of code above that script block, so in effect > two script blocks must be evaluated. It looks like the first one is > being evaluated, but I''m not sure.I just tried blowing out the first script block, still no luck with the other one. For some reason, even something as simple as <script type="text/javascript"> alert("Hello"); </script> isn''t working. _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Then update.aspx probably isn''t returning to you what you expect. When I had bugs I didn''t think it was my server code either, but it was. -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Brad Ediger Sent: Tuesday, April 18, 2006 4:14 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] [Prototype] evalScripts not working for me>> > I''m working in FF for right now. Incidentally, I tried the above > code before and it didn''t work. It''s like the scripts aren''t being > evaluated at all. > > I have one more block of code above that script block, so in effect > two script blocks must be evaluated. It looks like the first one is > being evaluated, but I''m not sure.I just tried blowing out the first script block, still no luck with the other one. For some reason, even something as simple as <script type="text/javascript"> alert("Hello"); </script> isn''t working.
This is the exact code being returned from update.aspx, as returned through FireBug (except for some linebreaks for quasi-readability). None of the JS in that "test = function()" JS block appears to be executed. <div class="service_body" id="area_279" style="width: 100%"> <script type=''text/javascript''> services[''service279''] = new Service(); </script> <table class="service"> <tr><td valign=''top''><div class=''service_header''><div style=''float: right'' id="minimize_buttons_279"><a href="javascript:minimize_service (279,1);"><img src="images/pieces/service_minimize.gif" style="border: none;" alt="Minimize" /></a><a href="javascript:close_service(279);"><img src="images/pieces/ service_close.gif" style="border:none" alt="Close" /></a></div><div style="padding: 3px;">myLINKS</div></div></td></tr> <tr id="service_body_279"><td> <form action="Profile/update.aspx" method="post" id="edit_form_279"> <input type="hidden" name="action" value="update_data" /> <input type="hidden" name="ServiceID" value=279 /> <input type="hidden" name="target_action" value="show" /> <script type="text/javascript"> test = function() { alert("test"); }; alert("test"); </script> <table class="small_input" id="edit_table_279"> <tr><td><input type="text" name="Profile_Links[0][title]" value="JBU" size="12" /></td> <td><input type="text" name="Profile_Links[0][url]" value="http://www.jbu.edu" size="12" /></td> </tr> <tr><td><input type="text" name="Profile_Links[1][title]" value="Slashdot" size="12" /></td> <td><input type="text" name="Profile_Links[1][url]" value="http://slashdot.org/" size="12" /></td> </tr> </table> <input type="button" onclick="test();" value="test" /> <p><input type="button" value="Save" onclick="submit_edit(279, ''area_279''); return false;" /> <input type="button" value="Cancel" onclick="revert_edit(279)" /></form></p></td></tr></table></div> -- Brad Ediger 866-EDIGERS On Apr 18, 2006, at 4:21 PM, Daniel Elmore wrote:> Then update.aspx probably isn''t returning to you what you expect. > When I had > bugs I didn''t think it was my server code either, but it was. > > > > -----Original Message----- > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of > Brad > Ediger > Sent: Tuesday, April 18, 2006 4:14 PM > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: Re: [Rails-spinoffs] [Prototype] evalScripts not working > for me > >>> >> I''m working in FF for right now. Incidentally, I tried the above >> code before and it didn''t work. It''s like the scripts aren''t being >> evaluated at all. >> >> I have one more block of code above that script block, so in effect >> two script blocks must be evaluated. It looks like the first one is >> being evaluated, but I''m not sure. > > I just tried blowing out the first script block, still no luck with > the other one. For some reason, even something as simple as > > <script type="text/javascript"> > alert("Hello"); > </script> > > isn''t working. > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Brad Ediger wrote:> This is the exact code being returned from update.aspx, as returned > through FireBug (except for some linebreaks for quasi-readability). > > None of the JS in that "test = function()" JS block appears to be executed.Well, if the response looks ok, what does your calling code look like exactly. Just trying to eliminate the easiest thing first. -- Michael Peters Developer Plus Three, LP
STUPID, STUPID, STUPID mistake. :-) I set evalScripts on the wrong Ajax.Updater call. The code I posted before works now. As a special bonus, I don''t have the variable scope issue I thought I did. Thanks a bunch!!! -- Brad Ediger 866-EDIGERS On Apr 18, 2006, at 4:40 PM, Michael Peters wrote:> > > Brad Ediger wrote: >> This is the exact code being returned from update.aspx, as returned >> through FireBug (except for some linebreaks for quasi-readability). >> >> None of the JS in that "test = function()" JS block appears to be >> executed. > > Well, if the response looks ok, what does your calling code look like > exactly. Just trying to eliminate the easiest thing first. > > -- > Michael Peters > Developer > Plus Three, LP > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs