I did battle with a similar situation recently. Ajax in widgets is no joke! Need to write some pretty crazy code to get things to work across instances. I’m not familiar with live query, but if you say it checks the DOM every second, I might have a less intense solution for you:
var get_widget_id = function ( selector ) {
var selector, widget_id = false;
var id_attr = $( selector ).closest( 'form' ).find( 'input[name="widget-id"]' ).val();
if ( typeof( id_attr ) != 'undefined' ) {
var parts = id_attr.split( '-' );
widget_id = parts[parts.length-1];
}
return parseInt( widget_id );
};
You can pass this function a selector or jQuery object and it will return the instance ID of the current instance. I could find no other way around this issue. Glad to hear I’m not the only one 🙂
Related Posts:
- How do register_sidebar() and get_sidebar() work together?
- Is There A Hook To Process The Content Of The Text Widget?
- Widgets vs. Theme Mods
- Widgets not working in Customizr but working in Appearance
- Get the sidebar ID in which the current widget was dropped
- How Can A Widget With Only One Instance Be Defined?
- How to exclude certain widget from showing up on home/front page? [duplicate]
- Customise search form in the Widget
- Created Widget Not Showing up on Admin Panel
- Schedule cron event from widget
- How to Register and Display Widget for Custom taxonomy
- register_sidebar ‘after_widget’ on custom-built widgets not implementing, caused nested widgets
- Use WordPress file upload in my plugin – on frontend and on backend?
- Add ‘Right Now’ widget to custom dashboard
- Count widgets of a certain type
- Widget Javascript code (ajax)
- Custom widget select options needs to stay selected after save
- Custom Widget form function common elements
- Updating Widget options in custom install.php
- Modify a theme to insert custom widgets?
- Customizer: widget-synced triggers twice
- How did I enable atom feeds in a fresh WP3 install?
- How to update preview when custom setting changed in my custom widget
- Child Theme – how to add new widget on a specific place?
- Warning: Creating default object… when altering Customize panels
- Adding custom field in all widgets, but at the top of the form, in admin area
- How do I change the markup only of a built-in widget?
- Is it possible to make widget return only data (eg, array)?
- Allow a Widget to be used one time only?
- Search widget will search everything in the site, how to limit to only search gallery name
- Disable widgets in customizer for sidebar
- Unable to edit the “customize” section and the “widget” section is populating unknown code
- Choose sidebars column in widgets.php page [closed]
- Can’t receive $args[ ] to my custom widget
- Organizing the position of widgetized areas in the backend
- how to convert Html block to dynamic widget?
- I’d like to move the Widgets Panel to the bottom of the list in Customizer
- WPML Plugin Not displaying multilingual Menus
- Create small dashboard widget
- Hook called before text widget save
- Widgets won’t save
- Customizing the Widget content markup
- Widget title markup in register_sidebar
- Sticky menu for WP custom menubars
- Create Widget or Enable Shortcodes in Sidebar
- How to append custom text to the output of ‘categories widget’?
- Customise the Category Widget
- What’s the right way to share data between widgets?
- Customize Widget Navigation
- Add custom border across footer widget area
- Customize section does not show my widget areas
- Widget recent comment filter by post meta_value
- How could I change contact details in the footer?
- Make Widget appear on Dashboard
- How to narrow the area between buttons on Helium theme sidebar? [closed]
- How to hide or remove a custom widget area when empty
- Set widget icon in Customizer?
- Execute function with jQuery if widget added or removed?
- Still desperate about multiple TinyMCEs in widgets – is there any good solution to this yet?
- Custom Admin Section
- How to define active widget with js in a customizer
- Confused about customising widgets
- Special characters showing in fallback font
- customize footer widgets area
- How do I include the sidebar (with Widgets) in a custom theme?
- What can I do to customize a widget provided with this plugin? from where have I to start?
- Hover Hide-Visible Additional CSS not working in WordPress website, but shows properly in Customize window
- Add a custom field for sorting the products in a specific category WOOCOMMERCE – Second try
- Multiple wp.editor in a custom widget using JQuery
- Search: how to extend the existing search to include a custom table
- Manage multiple domains from one backend
- Is there documentation reference for forms in menu and setting pages?
- Get ORIGINAL image links from get_post_gallery
- Custom link for wp_insert_post
- Login/Logout Session Sharing – Multiple WordPress Installations
- How to Get WordPress custom post data in WooCommerce product meta panel? [closed]
- change url for static files in /wp-admin with a cdn url
- Child Theme with multiple css files
- Static admin page for all multisite users
- Input in plugin widget does not allow spaces
- Using custom image resizing script in a page
- custom post type – page template
- Sub menu indicator that links to sub menu
- How to add custom control to a page?
- Get draggable widgets on Edit Post page
- Navigation label for page in custom theme
- Setup page on first login on multisite
- Unable to sanitize in customizer and escape in theme without removing ability for user to use “< br >” to insert a line break
- Auto login from custom registration form
- How to get Related Custom Posts?
- Background image not appearing
- Save & Publish disabled for two dimensional array Customizer
- Creating custom database table with crud operation
- Custom login with external provider iframe and data object
- 1 WordPress installation with 2 pages: every page gets a separate domain
- Development environment
- Diffrent User registration form for doctor and patient
- $wpdb->insert running multiple times?
- Deep customization of wp-login.php
- User can not login