« Return to Thread: Idea for comments.php

Re: Idea for comments.php

by Owen Winkler :: Rate this Message:

Reply to Author | View in Thread

Roland Haeder wrote:
>> Why not put the JavaScript in the header, via the wp_head action hook?
> The reason for this is that some want to pre-check via this code:
>
> <!-- Somewhere in the a-tag: //-->
> onSubmit="return submitHook();" onReset="return resetHook();"

Include a reference to prototype or a prototype-like library in wp_head,
and add an event observer:

Event.observe(window, 'load', function(e) {
$('commentform').appendChild(Builder.node("input", {
type: "hidden", name: "myfield", value: 'foo'});
// Or whatever
});

> Now we "just" need to add something like this inside of the <form></form>
> comtainer and everyone is happy:
>
> <?php wp_javascript(); ?>

Dumping javascript into the page to run as it's downloaded might not be
the best idea, especially since I've provided an example of how to do it
well, but here you go:


add_action('comment_form', 'my_php_function', 1);

function my_php_function($postid) {
        echo "Post ID: {$postid}";
}


This hook is already in the default theme's template code.  See
comments.php.

Owen

_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers

 « Return to Thread: Idea for comments.php