Ich arbeite an einem Plugin und bin auf ein Problem gestoßen, bei dem ich versuchte, die sortierbare jQuery-Benutzeroberfläche zu verwenden. Ich habe die Anweisung wie in befolgt Kodex aber Problem blieb. Die sortierbare jQuery-UI funktioniert nicht und Firebug sagt TypeError: jQuery(...).sortable is not a function
.
Ich laufe auf WordPress 3.6 und der Code ist:
<?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() {
?>
<table id="test">
<tbody>
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>5</td>
<td>6</td>
</tr>
<tbody>
</table>
<script>
jQuery('table#test tbody').sortable();
</script>
<?php
}