One way around this I’ve discovered since posting the above question is to instantiate inline via WP_Widget::form()
, with wp_enqueue_script()
loading the necessary JavaScript (exactly as mentioned above) — except, and here’s the key part, load the JavaScript in the header instead of the footer (fifth argument of wp_enqueue_script()
).
Which makes a lot of sense now that I think about it.
Even still, I hate using inline JavaScript — ever — and loading everything in the header is less than ideal.
As such, am leaving this question open in case anyone has a better idea.
Related Posts:
- WordPress 4.8: Using multiple WYSIWYG-Editors with media inside of Widgets how to?
- AJAX Contact Form Issue
- jQuery UI inside widget on admin page
- How do I pass the id of my widget to javascript in the form function?
- Render repeatable widget fields properly with Backbone.js
- Executing Javascript When a Widget is Added in the Backend
- Loading scripts only if a particular shortcode or widget is present
- changing wp-admin/widgets.php
- How to refresh Theme Customizer after change color inside wpColorPicker?
- How to Remove All Widgets from Dashboard?
- How can I delete all inactive widgets?
- How to Use JSON With AJAX?
- Completely disabling widgets
- add_page_menu to make shortcut to widgets
- How to get sidebar’s content inside admin-ajax?
- Remove/Add widgets from/to the Available Widgets pool
- wp-admin AJAX with Fetch API is done without user
- Run JS after widget settings are saved?
- How can I use AJAX to save/update a widget form?
- Widget code is not working on WordPress.com Hosted Blogs
- Include chat (HTML, js, css) in all pages of WordPress
- How to determine the number of widgets contained in a sidebar via customizer JS
- WP_enqueue_script() loads them always in wp_footer()?
- Add field to dashboard to update embedded URL on homepage?
- Dashboard Widgets – Add Admin Page With Same Functionality
- Drafts widget for admin page
- wp.template() returns tags in Ajax response
- Access Customizer widget instance form
- Issue understanding and using WordPress filters and actions
- Grabbing how Many Posts by Month for a Dashboard Widget
- Validating widget’s configuration data on Admin page
- Unable to load “wpColorPicker” on theme customize page
- wordpress widget missing jquery
- AJAX wp_insert_user WORKS but responds with “The site is not enabled”
- Custom widget is not appearing in the admin area
- How to remove Help tab and the Dashboard widget area’s empty border
- Widget page stopped loading
- How to add Ajax to the default widget calendar to support next/previous months loading?
- Issue with checked() echoing on to page
- Calling PHP function with AJAX
- Reload widget with AJAX
- Widget outputting JS as plain text
- admin-ajax.php & my wp-admin folder url showing in header
- Simple SCript Not Displayed in WIdth
- Loading scripts only if a particular shortcode or widget is present
- Handling dozens of sidebars
- Widget Admin page and Javascript enqueuing
- Widget stuck at particular point when dragging to bottom
- Widget Areas Still Appearing in WP ADMIN When They Shouldn’t
- Using AJAX in WordPress Widget
- how to use get_field_name in external ajax handler
- List.js inside WordPress widget
- Add text to Text Widget using Javascript
- jQuery “on” handler does not fire on newly inserted widgets [closed]
- Widget won’t work due to old JavaScript? Any ideas how to make it work? [closed]
- Limit number of Widgets in Sidebars
- check if registered sidebar is active & has widget content
- Programmatically edit the text of a widget
- Widget options get
- Custom WordPress+PHP+MYSQL+AJAX form, submit event not captured by Javascript, but does POST data to the DB
- How do i export the HTML from text widgets?
- Latest/Recent posts widget title link
- the_widget() and widget’s ID
- How to put Stack Exchange Flair as widget?
- How to speed up admin-ajax.php in wordpress
- Display single widget
- Global $wpdb is not showing correct data with function call
- Text widget doesn’t save the content
- Post ID displayed instead of title [closed]
- Custom post type editor with dynamic selects, one drop down populating a second second drop down not working
- Performance optimization of tree like structure
- Widget – link to page rather than absolute url
- Programmatically add widgets to sidebars
- url – ajax loaded but no JS
- Turn off “This is the Primary Sidebar Widget Area” message
- Inserting Read More Tag in Widget
- Display posts from category in post content?
- Widgets in WP 4.3 disappearing – How to fix?
- Making jQuery .change() event persistent after widget save
- Removing side bar widgets from GovPress theme
- Ajaxurl suddenly not defined
- Change Post Meta via AJAX from the posts list table
- Ajax requests from front-end with jQuery Fancybox
- How to test if the widgetized area has any widgets?
- Saving widget gets an undefined variable
- Dismiss Admin Pointer Temporarily
- Distinguish between different widgets of the same type
- links to Media Library content in sidebar per page
- widgets in footer?
- How do I load urls from an external .js file to my admin head?
- How can I remove WordPress element IDs and Class names in the HTML?
- Remove widgets on mobile front page without affecting desktop
- Widget settings disappear after refresh
- How to display author meta in a sidebar widget
- Is it ok not to set widget in the main page of a one page WordPress Theme?
- Recent Posts Widget URL / Domain change
- How do I convince this button to do something when it is clicked?
- Widget which displays thumbnails, but links to urls?
- Problem on register/login widgets
- Custom dashboard widget – load style only for added widget