-
- 141 Posts
How can I create a TV that acts as a button that when pressed runs a snippet?
The idea I have is within a Resource's Template Variables tab there would be a button that says "Email me" which when pressed would run a snippet that will email the current resource to a specific address.
I am aware of the EmailResource package which is good but there are way too many options for my end users and I really would like just one button, no other options. It avoids confusion.
Any suggestions welcome.
Many thanks in advance.
Glyn Szasz
Sydney, Australia
Happy to help (when can) and happy to learn
If you are a Sydney based MODX developer would love to hear from you. Please contact me.
-
- 5,888 Posts
should not be that difficult to create a custom-TV-inputtype, which would do that.
It could run a processor, when the button was clicked.
-
- 24,544 Posts
Take a look at the Notify extra's TV. It makes the TV caption a button that launches a page containing a snippet. It's a regular text TV.
For a long time now I've been meaning to rewrite EmailResource to work the same way, but I never seem to find the time to do it.
-
- 141 Posts
Quote from: BobRay at Sep 19, 2015, 05:43 PMTake a look at the Notify extra's TV. It makes the TV caption a button that launches a page containing a snippet. It's a regular text TV.
I notice within the caption you have the
<button id="nf-b" onClick="nf()"> Launch Notify </button>
Where is the nf() method? How do I link this to my snippet call?
Glyn Szasz
Sydney, Australia
Happy to help (when can) and happy to learn
If you are a Sydney based MODX developer would love to hear from you. Please contact me.
-
- 24,544 Posts
It's JavaScript in the code of the plugin. It creates a form, then appends it to the document and submits it. The action of the form is set to a page with the Notify snippet on it.