I don't understand - it uses the modern DOM events system, abstracted (partially) by tapestry.js, and further abstracted by the underlying prototype.js library. What is it you are asking?
zack1403 wrote: > Why doesnt tapestry attach events to the DOM instead of using onClick? > > Zack > > > Chris Lewis-5 wrote: > >> Hi Lucca, >> >> I'd been looking for a good example to use to write a wiki explaining >> the integration javascript by Tapestry, and your request gave me what I >> was looking for. Check out the article here: >> http://wiki.apache.org/tapestry/Tapestry5AndJavaScriptExplained (project >> source: http://thegodcode.net/tapestry5/jsclarity-project.zip). Apart >> from discussing in detail how T5 integrates JS, it shows how to create a >> mixin that can be added to link components. The mixin attaches js code >> to the component, so that when the link is clicked the user is presented >> with a confirmation box. Canceling the box cancels the click, while OK >> allows it to proceed as normal. This should be useful for those looking >> to add click confirmation functionality, but in your case I'm not sure >> if it will help. I ask you to try and see, but the problem will be how >> T5 attaches the js handlers for the ajax code (that is, they may fire >> before the confirmation code). >> >> Anyway, I think it will be helpful to those looking for such an >> explanation, and I hope it helps you. >> >> chris >> >> Luca Fossato wrote: >> >>> Hi all, >>> >>> I'm playing with actionlink and zones to understand T5 ajax functions >>> (Tapestry 5.0.11). >>> I'd like to define an actionlink like this one: >>> >>> <t:actionlink t:id="deleteLink" context="myContext" >>> t:zone="zoneToUpdate" onclick="confirm('are you sure to delete this >>> record ?');">delete</t:actionlink> >>> >>> where the onclick handler uses a javascript confirmation dialog to ask >>> to the user if he/she wants to delete the selected record. >>> It seems to me the Tapestry.linkZone js function "eats" the user >>> onclick handler and set its own - so it is not possible to execute any >>> js code prior to invoke the ajax call. >>> >>> Is it correct or am I missing something ? >>> >>> I tried to "fix" this behaviour, modifying a bit the Tapestry.linkZone >>> function (just an experiment): >>> >>> --- cut here --- >>> >>> /** Convert a form or link into a trigger of an Ajax update that >>> * updates the indicated Zone. >>> */ >>> linkZone : function(element, zoneDiv) >>> { >>> // ... original code until "Otherwise, assume it's just an ordinary >>> link." comment... >>> >>> // Otherwise, assume it's just an ordinary link. >>> var onClickValue = element.getAttribute("onclick"); >>> if (onClickValue != null) >>> { >>> element.setAttribute("tapestry5_onbeforeajax", onClickValue); >>> } >>> >>> var handler = function(event) >>> { >>> var onBeforeAjaxRes = true; >>> var onBeforeAjaxValue = >>> element.getAttribute("tapestry5_onbeforeajax"); >>> if (onBeforeAjaxValue != null) >>> { >>> onBeforeAjaxRes = eval(onBeforeAjaxValue); >>> } >>> >>> // execute the Ajax request only if the original onclick >>> attribute was not set or if the evaluation >>> // of the related function returned true; >>> if (onBeforeAjaxRes === undefined || onBeforeAjaxRes) >>> new Ajax.Request(element.href, { onSuccess : successHandler }); >>> >>> return false; >>> }; >>> >>> element.onclick = handler; >>> }, // end of linkZone function >>> >>> --- cut here --- >>> >>> that is a 10 minutes "fix", so probably it's not the best solution. >>> Anyway it seems to work fine for my experiment ;^) >>> To block the execution of the ajax call, do NOT use a return statement >>> inside the onclick handler. Example: >>> >>> <t:actionlink t:id="deleteLink" t:zone="zoneToUpdate" onclick="return >>> myFunction(myParam);">delete</t:actionlink> >>> >>> use this instead: >>> >>> <t:actionlink t:id="deleteLink" t:zone="zoneToUpdate" >>> onclick="myFunction(myParam);">delete</t:actionlink> >>> >>> because eval() returns the value of the last expression evaluated. >>> http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Functions:eval >>> >>> Does this stuff make sense for you ?? ;^) >>> >>> Thank you, >>> Luca Fossato >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [EMAIL PROTECTED] >>> For additional commands, e-mail: [EMAIL PROTECTED] >>> >>> >>> >>> >> -- >> http://thegodcode.net >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> >> > > -- http://thegodcode.net