Skip to content

Instantly share code, notes, and snippets.

@ronnieduke
Forked from stevewithington/muraAnnounceEvent.cfm
Last active August 29, 2015 14:01
Show Gist options
  • Save ronnieduke/f34d1c5782206d44269b to your computer and use it in GitHub Desktop.
Save ronnieduke/f34d1c5782206d44269b to your computer and use it in GitHub Desktop.
<!--- 1) Create a form with a hidden form field like shown below, and place it in a layout template, or in a display object, etc. --->
<form method="post">
<input type="text" name="myField" value="Some Value" />
<input type="hidden" name="myFormIsSubmitted" value="true">
<input type="submit">
</form>
<cfscript>
// 2) In the eventHandler.cfc (Site, Theme, Plugin, or other custom handler) you could listen for the even in one of Mura's eventHandlers such as 'onRenderStart'
public any function onRenderStart($){
if ( $.event('myFormIsSubmitted') == true ){
$.announceEvent('myEvent', $);
}
}
// 3) In the eventHandler.cfc (Site, Theme, Plugin, or other custom handler) you could then have your custom event
public any function onMyEvent($) {
WriteDump(var=$.event().getAllValues(), abort=true);
}
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment