• Resolved jwwicks

    (@jwwicks)


    Hello All,

    I’ve built this small plugin to allow for sorting of images for display.

    I’ve used this in the constructor of BWAutoImager

    add_action('admin_enqueue_scripts', array('BWAutoImager', 'register_scripts'));

    and

    /**
    		 * Register styles and scripts
    		 */
    		public function register_scripts(){
    			wp_register_style('bwimgr_style', plugins_url('/css/bwimgr.css', __FILE__));
    			wp_register_style('bwimgr_jqueryui_style', '//code.jquery.com/ui/1.10.3/themes/vader/jquery-ui.css');
    			wp_register_script('evzoom_js', plugins_url('/js/jquery.elevatezoom.js', __FILE__), array('jquery'));
    			wp_register_script('bwimgr_js', plugins_url('/js/bwimgr.js', __FILE__), array('jquery'));
    			self::queue_styles();
    			self::queue_scripts();
    		}
    
    		/**
    		 * Queue the plugins styles
    		 */
    		function queue_styles(){
    			wp_enqueue_style('bwimgr_style');
    			wp_enqueue_style('bwimgr_jqueryui_style');
    		}
    
    		/**
    		 * Queue the plugins javascript
    		 */
    		function queue_scripts(){
    			wp_enqueue_script('jquery-ui-core');
    			wp_enqueue_script('jquery-ui-widget');
    			wp_enqueue_script('jquery-ui-mouse');
    			wp_enqueue_script('jquery-ui-sortable');
    			wp_enqueue_script('bwimgr_js');
    			wp_enqueue_script('evzoom_js');
    		}

    These load fine in the initial screen. I can display and sort images in a extended WP_List_Table class. But, if I setup a column action

    $actions = array(
    				'rearrange'    => sprintf('<a href="?page=%s&action=%s&vstkno=%s">Rearrange</a>','bwauto-imager','rearrange',$item->vstockno),
    			);

    which goes to a subpage of my plugin, the custom and external js files load, jquery loads, but jquery-ui, jquery-ui-sortable, widget and mouse do not.

    I’ve tried every way I’ve found on the codex to queue the scripts on the subpage, including the following, but none of them work.

    $subpage = add_submenu_page(null, 'BWImager Image Sort', 'BWImager Rearrange', 'manage_options', 'bwauto-imager-sort', array('BWAutoImager', 'handle_sort'));
    			add_action( "admin_enqueue_scripts-$subpage", array('BWAutoImager', 'register_scripts'));

    The other queued scripts are being loaded just not the jquery-ui ones.

    Any hints as to what might be going on? I’ve seen other discussions that you’re going to have to load them from an external source on subpages, but is this correct?

    Thanks in advance,
    Jw

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Admin subpage not loading jQuery ui or sortable’ is closed to new replies.