reuben.m-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jan-27 03:15 UTC
Prototype not processing javascript
I''m trying to change over from Rails 1.1.6 to 1.2.1 and have discovered that either something is wrong with Prototype of else something has changed that I am not aware of and cannot find documentation on. (I just joined this group, so if this has already been cussed and discussed here or in another list then please point me in the right direction.) I am trying to use the "replace_html" feature, and instead of prototype processing the generated javascript, I get a big load of "try {Element.update( ...lots of javascript garbage... ) throw e }" dumped onto my screen in place of where the updated html should be. I encountered the same problem when I tried to work around it by using "replace" to swap out the whole element with updated innerHTML. The only way I could get around this problem was to use "replace" while changing the element id every time. (Which results in more code than should be necessary) Basically, whenever I try to update an element, the javascript doesn''t get picked up by prototype unless the id of the target element gets changed in the process. Is this a bug or am I completely missing something here? I''ve only been using Rails for a couple months now, so I''m a bit new at this... Thanks, -Reuben --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
I''ve been having the same difficulty... Although I''m not using Rails (I really wish I was). I''m using AJAX.Updater to make calls which in turn populate various DIV''s with data. However, none of the JavaScript gets executed (despite evalScripts being true). I''m trying to use AJAX.Updater to populate a DIV with a Dojo widget but all I''m getting is plain text and the widget won''t render. I think this is very common and all I''ve seen are little hacks to get code to work but I can''t see to get any of them working correctly. Take care, -Matt On Jan 26, 10:15 pm, "reube...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <reube...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m trying to change over from Rails 1.1.6 to 1.2.1 and have discovered > that either something is wrong with Prototype of else something has > changed that I am not aware of and cannot find documentation on. (I > just joined this group, so if this has already been cussed and > discussed here or in another list then please point me in the right > direction.) > > I am trying to use the "replace_html" feature, and instead of prototype > processing the generated javascript, I get a big load of "try > {Element.update( ...lots of javascript garbage... ) throw e }" dumped > onto my screen in place of where the updated html should be. > > I encountered the same problem when I tried to work around it by using > "replace" to swap out the whole element with updated innerHTML. The > only way I could get around this problem was to use "replace" while > changing the element id every time. (Which results in more code than > should be necessary) > > Basically, whenever I try to update an element, the javascript doesn''t > get picked up by prototype unless the id of the target element gets > changed in the process. > > Is this a bug or am I completely missing something here? I''ve only been > using Rails for a couple months now, so I''m a bit new at this... > > Thanks, > -Reuben--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hey Matthew, Matthew Williams a écrit :> I''m using AJAX.Updater to make calls which in turn populate various > DIV''s with data. However, none of the JavaScript gets executed > (despite evalScripts being true).Can you either put a minimalistic reproduction online for us to tinker with (that would be best), or failing that, post the *exact code* you''re using for the request (with details about what values you''re using that the code alone doesn''t show, such as form values, etc.) and the *exact dump* of the AJAX response? -- Christophe Porteneuve aka TDD tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
What Mime-type is the Dojo script sending? Walter On Jan 29, 2007, at 9:34 AM, Matthew Williams wrote:> > I''ve been having the same difficulty... Although I''m not using Rails > (I really wish I was). > > I''m using AJAX.Updater to make calls which in turn populate various > DIV''s with data. However, none of the JavaScript gets executed > (despite evalScripts being true). > > I''m trying to use AJAX.Updater to populate a DIV with a Dojo widget > but all I''m getting is plain text and the widget won''t render. > > I think this is very common and all I''ve seen are little hacks to get > code to work but I can''t see to get any of them working correctly. > > Take care, > -Matt > > On Jan 26, 10:15 pm, "reube...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <reube...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> I''m trying to change over from Rails 1.1.6 to 1.2.1 and have >> discovered >> that either something is wrong with Prototype of else something has >> changed that I am not aware of and cannot find documentation on. (I >> just joined this group, so if this has already been cussed and >> discussed here or in another list then please point me in the right >> direction.) >> >> I am trying to use the "replace_html" feature, and instead of >> prototype >> processing the generated javascript, I get a big load of "try >> {Element.update( ...lots of javascript garbage... ) throw e }" dumped >> onto my screen in place of where the updated html should be. >> >> I encountered the same problem when I tried to work around it by using >> "replace" to swap out the whole element with updated innerHTML. The >> only way I could get around this problem was to use "replace" while >> changing the element id every time. (Which results in more code than >> should be necessary) >> >> Basically, whenever I try to update an element, the javascript doesn''t >> get picked up by prototype unless the id of the target element gets >> changed in the process. >> >> Is this a bug or am I completely missing something here? I''ve only >> been >> using Rails for a couple months now, so I''m a bit new at this... >> >> Thanks, >> -Reuben > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Quick background on the site... Index.cfm (Coldfusion, ugh) has 3 DIV''s that get populated with various AJAX calls. The main content DIV gets populated based on an AJAX.Updater call from one of the other DIV''s. Inside the data that gets populated in the main content DIV has a DIV inside itself. I would like to click on an item in my content DIV (which was placed there from an AJAX.Updater call) and populate a DIV. Here is some code... // AJAX.Updater call to populate the DIV inside the main content DIV // This works fine but it puts plaintext in the DIV and not the rendered widget. function getLrudetail(selected_value){ var url = ''getlrudetail.cfm''; var pars = ''id=''+selected_value; var target = ''lruSpace''; var myAjax = new Ajax.Updater(target, url, {method: ''get'', parameters: pars, evalScripts: true}); } //getlrudetail.cfm - The content I want to populate the DIV (rendered) <meta http-equiv="Context-Type" content="text/html; charset=UTF-8"> <html> <!-- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> --> <CFSETTING SHOWDEBUGOUTPUT="No"> <head> <title>TabContainer Demo</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </meta> <script type="text/javascript" src="include/dojo.js"></script> <script> dojo.require("dojo.widget.TabContainer"); dojo.require("dojo.widget.LinkPane"); dojo.require("dojo.widget.ContentPane"); dojo.require("dojo.widget.LayoutContainer"); dojo.require("dojo.widget.Checkbox"); </script> <style type="text/css"> body { font-family : sans-serif; } .dojoTabPaneWrapper { padding : 10px 10px 10px 10px; } </style> </head> <body> <p>These tabs are made up of local and external content. Tab 1 and Tab 2 are loading files tab1.html and tab2.html. Tab 3 and Another Tab are using content that is already part of this page.</p> <div id="mainTabContainer" dojoType="TabContainer" style="width: 100%; height: 70%" selectedTab="tab1" > <div id="tab1" dojoType="ContentPane" label="Tab 1" > <h1>First Tab</h1> I''m the first tab and my content is local. Try clicking tab#2. It''s loading remotely. <input type="checkbox" name="cb1" id="cb1" dojoType="Checkbox" /> <label for="cb1">hello world</label> </div> <a dojoType="LinkPane" href="../../tests/widget/tab2.html" refreshOnShow="true" style="display: none">Tab 2</a> <div dojoType="ContentPane" label="Tab 3" style="display: none"> <h1>I am tab 3</h1> <p>Did you know that the children of a TabContainer can be any widget, such as a SplitContainer or LayoutContainer? The next tab is itself a TabContainer...</p> </div> <div id="subTabContainer" dojoType="TabContainer" label="Sub TabContainer"> <a dojoType="LinkPane" href="../../tests/widget/ tab1.html" style="display: none">SubTab 1</a> <a dojoType="LinkPane" href="../../tests/widget/tab2.html" selected="true">SubTab 2</a> </ div> </div> </body> </html> getlrudetail.cfm viewed by itself works fine, the Dojo widget is rendered and it works great. However, when I use it with AJAX.Updater all I get back is plaintext with no rendering. I know evalScripts: true ignores inline JavaScript or something but I quite haven''t figured out the hack to get it to work the way I want and have the Dojo widget render itself. I''m guessing I have a scope issue somewhere since I''m essentially populating a div inside another div each populated by AJAX.Updater calls. Not much of a JavaScript guru so any help would be appreciated. This site is for internal use only so this is the best I can do for posting code. Thanks! On Jan 29, 9:37 am, Christophe Porteneuve <t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org> wrote:> Hey Matthew, > > Matthew Williams a �crit : > > > I''m using AJAX.Updater to make calls which in turn populate various > > DIV''s with data. However, none of the JavaScript gets executed > > (despite evalScripts being true).Can you either put a minimalistic reproduction online for us to tinker > with (that would be best), or failing that, post the *exact code* you''re > using for the request (with details about what values you''re using that > the code alone doesn''t show, such as form values, etc.) and the *exact > dump* of the AJAX response? > > -- > Christophe Porteneuve aka TDD > t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
reuben.m-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Feb-06 02:45 UTC
Re: Prototype not processing javascript
@Matthew Williams: Thought I would post in case you hadn''t figured the problem out. (I got help on another list) The source of your problem is that you''re using AJAX.Updater instead of AJAX.Request. Use the Request method when you expect to get something that is more than just plain text, i.e. javascript. On Jan 29, 1:03 pm, "Matthew Williams" <matthew.d.willi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Quick background on the site... Index.cfm (Coldfusion, ugh) has 3 > DIV''s that get populated with various AJAX calls. The main content > DIV gets populated based on an AJAX.Updater call from one of the other > DIV''s. Inside the data that gets populated in the main content DIV > has a DIV inside itself. I would like to click on an item in my > content DIV (which was placed there from an AJAX.Updater call) and > populate a DIV. > > Here is some code... > // AJAX.Updater call to populate the DIV inside the main content DIV > // This works fine but it puts plaintext in the DIV and not the > rendered widget. > function getLrudetail(selected_value){ > var url = ''getlrudetail.cfm''; > var pars = ''id=''+selected_value; > var target = ''lruSpace''; > var myAjax = new Ajax.Updater(target, url, {method: ''get'', > parameters: pars, evalScripts: true}); > > } > > //getlrudetail.cfm - The content I want to populate the DIV (rendered) > <meta http-equiv="Context-Type" content="text/html; charset=UTF-8"> > <html> > <!-- > <!DOCTYPE html > PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> > --> > <CFSETTING SHOWDEBUGOUTPUT="No"> > <head> > <title>TabContainer Demo</title> > <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> > </meta> > <script type="text/javascript" src="include/dojo.js"></script> > <script> > dojo.require("dojo.widget.TabContainer"); > dojo.require("dojo.widget.LinkPane"); > dojo.require("dojo.widget.ContentPane"); > dojo.require("dojo.widget.LayoutContainer"); > dojo.require("dojo.widget.Checkbox"); > </script> > <style type="text/css"> > body { > font-family : sans-serif;} > > .dojoTabPaneWrapper { > padding : 10px 10px 10px 10px; > > } > > </style> > </head> > <body> > <p>These tabs are made up of local and external content. Tab 1 and Tab > 2 are loading files tab1.html and tab2.html. Tab 3 and Another Tab are > using content that is already part of this page.</p> > <div id="mainTabContainer" dojoType="TabContainer" style="width: 100%; > height: 70%" selectedTab="tab1" > > <div id="tab1" dojoType="ContentPane" label="Tab 1" > > <h1>First Tab</h1> > I''m the first tab and my content is local. Try clicking tab#2. > It''s loading remotely. > <input type="checkbox" name="cb1" id="cb1" dojoType="Checkbox" /> > <label for="cb1">hello world</label> > </div> > <a dojoType="LinkPane" href="../../tests/widget/tab2.html" > refreshOnShow="true" style="display: none">Tab 2</a> > <div dojoType="ContentPane" label="Tab 3" style="display: none"> > <h1>I am tab 3</h1> > <p>Did you know that the children of a TabContainer can be any > widget, such as a SplitContainer or LayoutContainer? The next tab is > itself a TabContainer...</p> > </div> > <div id="subTabContainer" dojoType="TabContainer" label="Sub > TabContainer"> <a dojoType="LinkPane" href="../../tests/widget/ > tab1.html" style="display: none">SubTab 1</a> <a dojoType="LinkPane" > href="../../tests/widget/tab2.html" selected="true">SubTab 2</a> </ > div> > </div> > </body> > </html> > > getlrudetail.cfm viewed by itself works fine, the Dojo widget is > rendered and it works great. However, when I use it with AJAX.Updater > all I get back is plaintext with no rendering. I know evalScripts: > true ignores inline JavaScript or something but I quite haven''t > figured out the hack to get it to work the way I want and have the > Dojo widget render itself. > > I''m guessing I have a scope issue somewhere since I''m essentially > populating a div inside another div each populated by AJAX.Updater > calls. > > Not much of a JavaScript guru so any help would be appreciated. > > This site is for internal use only so this is the best I can do for > posting code. > > Thanks! > > On Jan 29, 9:37 am, Christophe Porteneuve <t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org> wrote: > > > Hey Matthew, > > > Matthew Williams a ?crit : > > > > I''m using AJAX.Updater to make calls which in turn populate various > > > DIV''s with data. However, none of the JavaScript gets executed > > > (despite evalScripts being true).Can you either put a minimalistic reproduction online for us to tinker > > with (that would be best), or failing that, post the *exact code* you''re > > using for the request (with details about what values you''re using that > > the code alone doesn''t show, such as form values, etc.) and the *exact > > dump* of the AJAX response? > > > -- > > Christophe Porteneuve aka TDD > > t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---