Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am writing a plugin for a customer and I need to use lightbox/thickbox/fancybox/etc in my admin piece. No matter what jquery plugin I use, and I'm using wp_enqueue_style and wp_enqueue_script, nothing seems to work. No errors or anything. I click a link to open a hidden DIV, and nothing happens.

Anyone have an alternative or a solution?

Thanks.

share|improve this question
add comment

1 Answer 1

Don't know if this could help you, I used this to manage a image field from a meta-box in the post admin page :

add_action( 'load-post.php', 'ImageOnSlider_scripts' );
add_action( 'load-post-new.php', 'ImageOnSlider_scripts' );


function ImageOnSlider_scripts() {
wp_enqueue_script('media-upload');
wp_enqueue_script('thickbox');
wp_register_script('my-upload', WP_THEME_URL.'/js/name_of_script.js', array('jquery','media-upload','thickbox'));
 wp_enqueue_script('my-upload');
 wp_enqueue_style('thickbox');
 }

and the JS :

jQuery(document).ready(function() {

jQuery('#upload_image_button').click(function() {
 formfield = jQuery('#input-ImageOnSlider').attr('name');
 tb_show('', 'media-upload.php?type=image&TB_iframe=true');
 return false;
});

window.send_to_editor = function(html) {
 imgurl = jQuery('img',html).attr('src');
 jQuery('#input-ImageOnSlider').val(imgurl);
 tb_remove();
}   

});

(name the buttons or link accordingly to the js, or modify js)

share|improve this answer
1  
You can also use add_thickbox() for easier access to the thickbox.js stuff on admin. –  kaiser Nov 19 '11 at 23:47
    
That was really helpfull for me ;) :) Thanks a lot –  Merianos Nikos Jan 26 '12 at 13:01
add comment

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.