Including jQuery UI Sortable in WordPress admin page

admin

Administrator
Staff member
I'm working on a plugin and encountered a problem where trying to make use of the jQuery UI Sortable. I followed the instruction as in <a href="http://codex.wordpress.org/Function...cripts_Only_on_a_Plugin_Administration_Screen" rel="noreferrer">Codex</a> but issue remained. The jQuery UI sortable does not function and Firebug says
Code:
TypeError: jQuery(...).sortable is not a function
.

I'm running on WordPress 3.6 and the code is:

Code:
&lt;?php
/*
Plugin Name: Name
Description: Description
Version: 0.1
Author: Bloorchi
*/

add_action( 'admin_menu', 'my_plugin_admin_menu' );

function my_plugin_admin_menu() {
    add_action('admin_print_scripts-' . $page_hook_suffix, 'my_plugin_admin_scripts');
    $page_hook_suffix = add_submenu_page( 'edit.php', 'My Plugin', 'My Plugin', 'manage_options', 'my_plugin-options', 'my_plugin_manage_menu' );
}

function my_plugin_admin_scripts() {
    wp_enqueue_script( 'jquery-ui-sortable' );
}

function my_plugin_manage_menu() {
?&gt;
&lt;table id="test"&gt;
    &lt;tbody&gt;
        &lt;tr&gt;
            &lt;td&gt;1&lt;/td&gt;
            &lt;td&gt;2&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;3&lt;/td&gt;
            &lt;td&gt;4&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;5&lt;/td&gt;
            &lt;td&gt;6&lt;/td&gt;
        &lt;/tr&gt;  
    &lt;tbody&gt;    
&lt;/table&gt;
&lt;script&gt;
    jQuery('table#test tbody').sortable();
&lt;/script&gt;
&lt;?php
}