Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8198331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:55:45+00:00 2026-06-07T05:55:45+00:00

I am creating my first wordpress widget and I am having problems using jquery

  • 0

I am creating my first wordpress widget and I am having problems using jquery ui sortable in admin widgets page.

From what I have seen on my research, WordPress already includes jquery (and jquery ui libraries), but in order to use it I have to use wp_enqueue_script.

Which I did.

But only some of the jquery code works. The jquery ui sortable does not work.

Here is my abc_categories_widget.js

jQuery(document).ready(function() {
    // The following doesn't seem to be working
    jQuery("#abc_product_categories_sortable").sortable({
        cursor: 'move'
    });

    // The below statements work as expected
    jQuery('#abc_product_categories_sortable').disableSelection();
    jQuery('#abc_product_categories_sortable li').disableSelection();
});

Here is the relevant code my widget

    function form($instance) {
        wp_enqueue_script('abc_categories_widget_js', plugin_dir_url(__FILE__) . 'abc_categories_widget.js', array('jquery','jquery-ui-sortable'), '1.0', true);
        wp_enqueue_style('abc_categories_widget_css', plugin_dir_url(__FILE__) . 'css/jquery-ui-1.8.21.custom.css');

        $abc_categories = $instance['abc_product_categories'];

        global $wpdb;
        $product_categories = $wpdb->get_results('SELECT * FROM ' . $wpdb->prefix . 'abc_categories', ARRAY_A);
?>
        <ul id="abc_product_categories_sortable" class="ui-sortable">
        <?php foreach($product_categories as $a_category) { ?>
            <li id="<?php echo 'cid_' . $a_category['category_id']; ?>" class="ui-state-default" style="padding:5px 10px"><?php echo $a_category['category_name']; ?></li>
        <?php } ?>
        </ul>
<?php
    }
}

Anyone knows what might be the problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T05:55:46+00:00Added an answer on June 7, 2026 at 5:55 am

    I have managed to solve my problem by wrapping <ul> in a <div>

    i.e. in php code

    <div id="abc_product_categories_sortable">
            <ul id="abc_product_categories_sortable_list" class="ui-sortable">
            <?php foreach($product_categories as $a_category) { ?>
                <li id="<?php echo 'cid_' . $a_category['category_id']; ?>" class="ui-state-default" style="padding:5px 10px"><?php echo $a_category['category_name']; ?></li>
            <?php } ?>
            </ul>
    <div>
    

    and in my javascript code

    jQuery(document).ready(function() {
        jQuery("#abc_product_categories_sortable ul").sortable({
            cursor: 'move'
        });
    
        jQuery('#abc_product_categories_sortable ul').disableSelection();
        jQuery('#abc_product_categories_sortable li').disableSelection();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating my first wordpress plugin. one of the questions i have is
I am creating my first site from scratch using PHP, MySQL, CSS, HTML, and
I'm creating my first application and I have a window consisting of multiple subclasses
I am creating my first (!) database, and I have run into an issue
I'm creating my first non-console game in Visual C#. I have a player which
I'm using svn for the first time, to maintain a custom version of Wordpress.
I'm creating my first API and am using Ruby on Rails. The API will
This is my first wordpress site. I am creating a local community site and
I'm creating my first android app that will make use of SQlite. I have
Im creating my first app for Windows 8 and i have a question. In

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.