Re: T5: Javascript problem
I dont like this way of refering to nodes ( document.entryForm.oosComment ) i'm not sure how many browsers fully support this but it looks like this can work when nodes have the name attribute set. If i remember correctly, T5.1 used to include a name in each form but this was removed in 5.2 - see https://issues.apache.org/jira/browse/TAP5-796 So, anyway, see if your nodes have id, and just reference them in that way using either document.getElementById or prototype's $$ On Thu, Dec 16, 2010 at 10:51, Newham, Cameron cameron.new...@bl.uk wrote: Hi! Another simple question. I had an application running under T5.1 and I've now moved to 5.2. I notice my Javascript is now broken. I have this function in my .tml file: SCRIPT type=text/JavaScript LANGUAGE=JavaScript function checkOOS(myCheck) { if(myCheck.checked) { document.entryForm.oosComment.disabled = false; document.entryForm.oosComment.focus(); } else { document.entryForm.oosComment.disabled = true; } } /SCRIPT Which turns a select on and off by clicking a checkbox via onclick. While the JavaScript function is called, it no longer updates the disabled attribute of oosComment. Should I be adding my JavaScript with JavaScriptSupport (and if so, where is documentation or an example? The only mention of JavaScript I can find is in the HOW-TOs which show it being added to the .tml file directly in a script block). Also, why is this now partially non-functioning in 5.2? It seems that document.entryForm.oosComment.disabled is incorrect for referring to component oosComment. Yet this works fine under 5.1. My Form is called entryForm and oosComment is inside that. The page hasn't changed since it worked under 5.1 but, in that case, it seems I've been doing something wrong all along even though it worked. c. -- Andreas Andreou - andy...@apache.org - http://blog.andyhot.gr Tapestry PMC / Tacos developer Open Source / JEE Consulting - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
RE: T5: Javascript problem
Thanks Andreas. Yes, name attribute was the problem. I've changed to using getElementById and it's working again. c. -Original Message- From: andre...@gmail.com [mailto:andre...@gmail.com] On Behalf Of Andreas Andreou Sent: 16 December 2010 10:12 To: Tapestry users Subject: Re: T5: Javascript problem I dont like this way of refering to nodes ( document.entryForm.oosComment ) i'm not sure how many browsers fully support this but it looks like this can work when nodes have the name attribute set. If i remember correctly, T5.1 used to include a name in each form but this was removed in 5.2 - see https://issues.apache.org/jira/browse/TAP5-796 So, anyway, see if your nodes have id, and just reference them in that way using either document.getElementById or prototype's $$ On Thu, Dec 16, 2010 at 10:51, Newham, Cameron cameron.new...@bl.uk wrote: Hi! Another simple question. I had an application running under T5.1 and I've now moved to 5.2. I notice my Javascript is now broken. I have this function in my .tml file: SCRIPT type=text/JavaScript LANGUAGE=JavaScript function checkOOS(myCheck) { if(myCheck.checked) { document.entryForm.oosComment.disabled = false; document.entryForm.oosComment.focus(); } else { document.entryForm.oosComment.disabled = true; } } /SCRIPT Which turns a select on and off by clicking a checkbox via onclick. While the JavaScript function is called, it no longer updates the disabled attribute of oosComment. Should I be adding my JavaScript with JavaScriptSupport (and if so, where is documentation or an example? The only mention of JavaScript I can find is in the HOW-TOs which show it being added to the .tml file directly in a script block). Also, why is this now partially non-functioning in 5.2? It seems that document.entryForm.oosComment.disabled is incorrect for referring to component oosComment. Yet this works fine under 5.1. My Form is called entryForm and oosComment is inside that. The page hasn't changed since it worked under 5.1 but, in that case, it seems I've been doing something wrong all along even though it worked. c. -- Andreas Andreou - andy...@apache.org - http://blog.andyhot.gr Tapestry PMC / Tacos developer Open Source / JEE Consulting - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5: Javascript problem
Hi Cameron, On Thu, Dec 16, 2010 at 8:03 AM, Newham, Cameron cameron.new...@bl.ukwrote: Should I be adding my JavaScript with JavaScriptSupport (and if so, where is documentation or an example? The only mention of JavaScript I can find is in the HOW-TOs which show it being added to the .tml file directly in a script block). I haven't read precisely your mail but I think I can answer that part... I 've been reading the mailing list for a while and I think adding javascript blocks is not recommended, instead you should write javascript in .js files and add them by means of annotations in the Java class. About t5/js documentation I can tell you about this link I found useful: http://wiki.apache.org/tapestry/Tapestry5AndJavaScriptExplained please take into account that annotation's names may vary between version 5.1.x.x and 5.2.x.x... I don't remember quite well about that. finally you can browse mailing list archives: http://tapestry.1045711.n5.nabble.com/Tapestry-User-f2375125.html hope that helps cheers. Nicolas.-
Re: T5: Javascript problem
Yes, it's true it might not be the fastest or easiest way, but I think it's good that Tapestry forces you to things the right way. Nicolás.-
Re: T5: Javascript problem
One use case I have for putting javascript in .tml is to get a function to execute after a zone update. Due to Tapestry attaching onclick event handlers to actionlinks (as opposed to using onclick attribute), it's not that easy afaik to guarantee your own method will get called afterwards (the DOM standard does not specify in which order attached events should be fired). So at the bottom of my zone I have a scriptmyFunction();/script block. Seems to work, although is probably a horrible hack and not the right way to do things... :) R. On Thu, 2010-12-16 at 11:45 -0300, Nicolas Barrera wrote: Yes, it's true it might not be the fastest or easiest way, but I think it's good that Tapestry forces you to things the right way. Nicolás.- - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org