Vipin
Vipin

Reputation: 115

Jquery sortable function is not working in wordpress

Here is my code

jQuery:

jQuery(document).ready(function(){
    jQuery('#admin-page-wrapper ul').sortable({cursor: 'move'});

});

Here is my order of jquery which are enqued

 wp_enqueue_script('jquery');
    wp_enqueue_script('jquery-ui-core');

And here is my plugin code

<div id="admin-page-wrapper">
        <h2>Published Pages</h2>
        <?php 
            $pages = new WP_Query(array('post_type'=>'page','post_status'=>'publish','posts_per_page'=>'-1','order'=>'ASC'));
        ?>
            <ul id="dashboard-page">
          <?php  if($pages -> have_posts()){
                while($pages -> have_posts()){
                    $pages->the_post(); ?>
                    <li class="dashboard-item"><?php echo the_title(); ?></li>
                <?php }
            } ?>
            </ul>
</div>

Upvotes: 0

Views: 8224

Answers (1)

AWA
AWA

Reputation: 446

Add 3rd script & add it as last one:

wp_enqueue_script( 'jquery-ui-sortable');

You can find a list of all WordPress built in scripts at this page:

https://codex.wordpress.org/Function_Reference/wp_enqueue_script

Upvotes: 9

Related Questions