Hi Jim, Thanks for the suggestion. I haven't tried that, so I'll give it a try.
Tauren On 5/5/07, James McLaughlin <[EMAIL PROTECTED]> wrote: > hmm. > > Have you run it with firebug or venkman? When I've run into this before it > was usually because the script had a parse error causing the interpreter to > barf and not load the rest of the script. > > best, > jim > > > On 5/5/07, Tauren Mills <[EMAIL PROTECTED]> wrote: > > > > I'm having a strange problem executing javascript functions from ajax. > > Some scripts work and some don't. I've got this java code: > > > target.appendJavascript("toggleSelection( > document.getElementById('"+getComponent().getMarkupId()+"'))"); > > > > And in the html I've got this: > > > > <wicket:head> > > <script type="text/javascript" src="js/reports.js"></script> > > </wicket:head> > > > > The function toggleSelection is in reports.js. > > > > If I make toggleSelection just a simple script, it runs fine. But if > > I add more code to it, I sometimes get the following error response. > > I've verified that reports.js is included in the html source. > > > > INFO: > > INFO: Initiating Ajax POST request on > > > /sa/app?wicket:interface=:3:tabs:panel:reportForm:availReport:availRow:3:row:scheduled:-1:IUnversionedBehaviorListener&wicket:behaviorId=0&wicket:ignoreIfNotActive=true&random= > 0.5721591389578449 > > INFO: Invoking pre-call handler(s)... > > INFO: Received ajax response (204 characters) > > INFO: > > <?xml version="1.0" > > > encoding="UTF-8"?><ajax-response><evaluate><![CDATA[toggleSelection( > document.getElementById('tabs_panel_reportForm_availReport_availRow_3_row_scheduled'))]]></evaluate></ajax-response> > > INFO: Response parsed. Now invoking steps... > > ERROR: Exception evaluating javascript: ReferenceError: > > toggleSelection is not defined > > INFO: Response processed successfully. > > INFO: Invoking post-call handler(s)... > > > > I've gone through the JS code very carefully to see if there are any > > mistakes. I can't find any. Here is the code that causes the error: > > > > function toggleSelection(element) { > > var cn = element.parentNode.parentNode.className; > > alert(cn); > > switch(cn) { > > case "odd": > > alert("in odd"); > > > element.parentNode.parentNode.className = "oddSelected"; > > alert("out odd"); > > break; > > case "oddSelected"): > > alert("in oddSelected"); > > > element.parentNode.parentNode.className = "odd"; > > alert("out oddSelected"); > > break; > > case "even": > > alert("in even"); > > > element.parentNode.parentNode.className = "evenSelected"; > > alert("out even"); > > break; > > case "evenSelected": > > alert("in evenSelected"); > > > element.parentNode.parentNode.className = "even"; > > alert("out evenSelected"); > > break; > > default: > > break; > > } > > alert("done"); > > } > > > > I have it working now by using a different toggleSelection script. > > Now the output is this: > > > > INFO: > > INFO: Initiating Ajax POST request on > > > /sa/app?wicket:interface=:7:tabs:panel:reportForm:availReport:availRow:4:row:scheduled:-1:IUnversionedBehaviorListener&wicket:behaviorId=0&wicket:ignoreIfNotActive=true&random= > 0.8455243647238795 > > INFO: Invoking pre-call handler(s)... > > INFO: Received ajax response (204 characters) > > INFO: > > <?xml version="1.0" > > > encoding="UTF-8"?><ajax-response><evaluate><![CDATA[toggleSelection( > document.getElementById('tabs_panel_reportForm_availReport_availRow_4_row_scheduled'))]]></evaluate></ajax-response> > > INFO: Response parsed. Now invoking steps... > > INFO: Response processed successfully. > > INFO: Invoking post-call handler(s)... > > > > And the code is this: > > > > function toggleSelection(element) { > > var cn = element.parentNode.parentNode.className; > > if (cn == "odd") { > > element.parentNode.parentNode.className > = "oddScheduled"; > > } > > else if (cn == "oddScheduled") { > > element.parentNode.parentNode.className = > "odd"; > > } > > else if (cn == "even") { > > > element.parentNode.parentNode.className = "evenScheduled"; > > } > > else if (cn == "evenScheduled") { > > element.parentNode.parentNode.className > = "even"; > > } > > } > > > > What causes that type of Error message in the ajax window? Is it > > javascript that doesn't execute properly? Why would it say the method > > is undefined? Is there something wrong with that first script? I > > realize this isn't a javascript list, but I really don't see anything > > wrong with it. > > > > Thanks, > > Tauren > > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by DB2 Express > > Download DB2 Express C - the FREE version of DB2 express and take > > control of your XML. No limits. Just data. Click to get it now. > > http://sourceforge.net/powerbar/db2/ > > _______________________________________________ > > Wicket-user mailing list > > Wicket-user@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/wicket-user > > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Wicket-user mailing list > Wicket-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/wicket-user > > ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user