0

I have a plugin adding a custom meta box to the comments editing page:

function on_admin_init() {
add_meta_box( 
'commentrating',
__( 'Voto recensione', FB_DT_TEXTDOMAIN ),
array( &$this, 'meta_box_voto' ),
'comment', 'normal', 'high'
);
}
function meta_box_voto($data) {
...
?>
<script>
jQuery(document).ready(function() {     
    alert("ah!");       
});
</script>
<?php
} ...

But the alert is called twice! Is this a WP or jQuery bug? Am I making any mistake?

Thanks!

P.S. If I put the alert into the first function it is only called once...

1

Put the JS in the admin_footer. If the Widgets are moved, your JS tag code can be duplicated hence called twice.

  • Great, I love you! – teocomi Nov 1 '11 at 9:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.