Re: [Xsltforms-support] Can you use dispatch to invoke a trigger?
Brought to you by:
alain-couthures
From: William V. <wve...@vi...> - 2014-03-03 19:18:22
|
Hi Mark, What you need is a custom event handler. First In you xf:model, declare an xf:action that handle a custom event (you assign the name), let's say "next-page", and include on it the actions on the trigger you want to call: <xf:action ev:event="next-page"> <!- lots of stuff here -> </xf:trigger> Second, call this event with the action xf:dispatch from the original trigger <xf:trigger id="next_parent"> <xf:label>Next Page</xf:label> <xf:action ev:event="DOMActivate"> <xf:dispatch name="next-page" id="model1" /> </xf:action> </xf:trigger> In this example, next-page is the name of the custom event and model1 is the id attribute of the xf:model that contains the event handler, if you don't have one, you must assign an id attribute like this. <xf:model id="model1" /> Then you can reuse the event handler just calling this code from any trigger or control on your XForms: <xf:dispatch name="next-page" id="model1" /> Hope this helps, William David Velásquez Director de Investigación y Desarrollo Visión Tecnológica S.A.S. www.visiontecnologica.com<http://www.visiontecnologica.com> Tel (57 4) 444 7292 Movil (57) 311 709 8421 Follow me @williamda De: Mark Lawson [mailto:tin...@gm...] Enviado el: lunes, 03 de marzo de 2014 9:09 a. m. Para: Xsl...@li... Asunto: [Xsltforms-support] Can you use dispatch to invoke a trigger? Hi all, Can you 'call' a trigger by using <xf:dispatch/> ? Say I have a <xf:repeat/> list of items with Next and Prev buttons at the bottom. It's a pretty long list so I want to duplicate the buttons at the top as well but I don't really want to duplicate the event code in these, I just want to get them to activate their respective originals. I've tried this sort of code below but no luck so far. <xf:trigger id="next_parent"> <xf:label>Next Page</xf:label> <xf:action ev:event="DOMActivate"> <!- lots of stuff here -> </xf:action> </xf:trigger> <!- this button just 'calls' it's parent <xf:trigger id="next_dummy"> <xf:label>Next Page</xf:label> <xf:action ev:event="DOMActivate"> <xf:dispatch id="next_parent" ev:event="DOMActivate"/> </xf:action> </xf:trigger> Rgds, Mark Lawson |