WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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...

share|improve this question
up vote 1 down vote accepted

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

share|improve this answer
    
Great, I love you! – teocomi Nov 1 '11 at 9:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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