The script you are loading will apply the sortable to all elements with the .mywidget-list
class just after the document has loaded.
Once you drop your widget inside a sidebar, a new .mywidget-list
element is created trough $.ajax, which cannot have your sortable function attached to it, because it’s new. If you save the widget, the form HTML gets replaced with $.ajax, so again a new element is created in the DOM.
There are two solutions that I know of:
- Put your JS inside the form method (inline javascript)
- Wrap your sortable call within a function that you hook on the ajaxComplete event. This means your function will run each time an ajax request completes. You might want to check here if the element already has a sortable attached, to avoid conflicts
Related Posts:
- Enabling jquery when dragging available widget to sidebar area
- How do I rebind event after widget save
- How to listen to color changes on the color picker?
- Ban certain widgets from certain sidebars
- Widget “Save” resetting jQuery hidden fields
- jQuery does not work in widget backend
- Trigger Submit Event when Widget is added to Sidebar
- How to enable “shift-click to edit this widget” functionality on a custom widget?
- Using jQuery in widget development
- cannot drag and drop widgets since wordpress 3.2.1
- AJAX Contact Form Issue
- jQuery UI inside widget on admin page
- WP_enqueue_script() loads them always in wp_footer()?
- Wrap the widget content with a div and get the widget title outside? [closed]
- Access Customizer widget instance form
- How i can widget ID get after drag for wordpress with jquery?
- wordpress widget missing jquery
- Making jQuery .change() event persistent after widget save
- Jquery checkbox -show posts with checked tags
- Using AJAX in WordPress Widget
- Custom tabs widget don’t work in google chrome, is blocked, do not change the tabs. Why?
- Multiple widgets in wordpress
- jQuery “on” handler does not fire on newly inserted widgets [closed]
- Where is the content of widgets stored in mysql table
- How to refresh Theme Customizer after change color inside wpColorPicker?
- How to Remove All Widgets from Dashboard?
- Determining a Widget Instance and Sidebar Location?
- Randomize widgets displayed in my sidebar [duplicate]
- Calling static method in the Widget Class
- Remove […] from RSS feed?
- Modifying recent post widget to include icons for post titles
- Unfiltered html in widget title not working
- How to process content in a widget? [duplicate]
- How to retrive widget title/data
- How do I embed in a text widget?
- Why use dynamic_sidebar() conditionally?
- WordPress Widget multiple use
- Contact Form in sidebar [closed]
- Display the date before the post title in recent posts widget
- More flexible sidebar and widget management
- Dynamic Sidebars On Multiple Subpages
- Can I remove a widget area without editing code?
- Cannot save widgets in custom sidebars
- Disable widgets on specific posts
- How to determine the number of widgets contained in a sidebar via customizer JS
- WordPress Plugins won’t save
- Toggle option in sidebar widgets
- Add field to dashboard to update embedded URL on homepage?
- widgetlogic and permalinks
- allow user to style widget backgound per widget
- I’m trying to find a basic plugin for displaying images in a widget [closed]
- A form in a custom widget
- Block-based Widgets Editor – how to enable a title
- Widgets in home.php redirect to index.php
- How to make a can’t hide widget?
- How to track whether the user has changed the value of the field in the widget or not?
- WordPress: How to embed a widget on a separate website?
- Widget on the right side of the page overlaps with the left side [closed]
- Making tags appear as an Unordered list instead of a ‘cloud’
- Shortcode not working in widget
- How to get options of all active widgets ?
- Display a widget on a specific type of archive
- Add a specific css to a widget
- Widget Title is not saving in backend
- Add class to on sidebar widget
- Save button is not working on custom widget
- WordPress update not saving
- WordPress Edit Button not appearing for widget in customizer
- WordPress database error – quick review
- Select two value from meta key and post meta
- How to add a text widget on the posts admin page?
- Widget select option not saving
- Changing the order of widgets according to current page?
- How to remove date in Recent Post widget?
- Your theme has 8 widget areas, but this particular page doesn’t display them
- A message to clients in the dashboard widget received from another site
- How to get individual values from custom widget?
- How would you return a value from an individual field in a custom widget?
- Can view Social Media buttons only in the private mode – why?
- Execute function with jQuery if widget added or removed?
- Before_widget won’t show up
- Widget Registration Problem
- Reload widget with AJAX
- Function for widget titles
- How do you add a widget to the side of a page
- Prevent widgets from disappearing when swtiching from parent to child theme
- Widget settings disappear after refreshing page
- Widgets Opening In New Window – Unwanted
- Randomizing the RSS Widget
- Allow end users to change settings of a widget
- Get widget locations in WordPress plugin
- Widget checkbox array empty on update function
- how to use get_field_name in external ajax handler
- Add custom class to a tags [closed]
- wordpress random widget widget
- WooCommerce Layered Nav Widget [closed]
- How do I get shortcode, widget and template tag CSS to load in the head only as required? [duplicate]
- How to exclude a widget from showing up on a page?
- How can I create my own widgets in WordPress? [closed]
- Widget block editor: Unable to collect checkbox values inside widget update() method