Forum Discussion
jgroves wrote:
I'd like some javascript to execute when a user clicks "post" when either begining a thread or replying.
This is very possible.
jgroves wrote:
Basically for many complicated reasons (too much detail to provide in this post)
Ahh the bane of the online forum.This is wildly off topic, but the reason this one gets in my way is that if I knew what problem you were trying to solve there might be a better way to do it. Like when the team who posts in our Blog spent weeks putting together a brief and then sent me a big pack on the feature they needed to develop for an essential tool. Until I pointed out we could just add a component for it.
But that's ok, let's solve the problem in front of us :)
The easiest way to do what you want is going to be to make your own custom components for the reply and post buttons.
Use CSS to hide the existing buttons and place yours there via studio.
Then write your javascript to check the post div on page load (why wait til it's clicked right :) ) and then either make the button generate an alert on click or function as normal.
You'll have to make sure you wrap the javascript in the Lithium wrapper so it queues up with the rest and executes after the page is ready.
I'd code it so it executes like this.
1. Page loads as normal, the post and reply buttons point to the reply page by default (this is your fallback for people without javascript enabled).
2. After the page is "ready" the code does a quick check of the right div and looks for the characters in question.
3. if it finds them it switches the innerHTML for the button to do an alert, or changes the button to disabled and shows a warning div.
4. if it doesn't find it, it does nothing.
This would cover you if the characters are found, if the characters are not found, and most of all if there is no javascript.
It's not perfect, it's a little clunky, and with javascript disabled people can still post.
It'll get the job done.
And leave me WILDLY curious what kind of content you're allowing to be posted but not replied to!
Related Content
- 11 years ago
- 10 years ago
- 14 years ago
- 12 years ago
- 11 years ago