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?
- Should I delete the default themes?
- Moving WP install from local to live, what about wp_posts GUID?
- Rename UPLOADS folder with custom WP_CONTENT_DIR
- Upgrading WordPress and Plugins; any Tips to Avoid Trouble?
- Modify column_author in WP_Comments_List_Table
- What are the ways to use WordPress as a user generated content site
- Adding Custom Link anchors in the top menu that points to specific sections of the site home page
- TinyMCE default link target to “_blank”
- setting a specific home page for logged in users
- Page with several user editable text content
- Fast way to add countries as a custom taxonomy term?
- Programmatically add a custom page/path/url/route to WordPress
- How to extend nav-menu-item-control data in Appearance > Customize?
- Is it possible to have one page with multiple items, or 2 blogs on a site?
- Fatal error in wp-admin/customize.php after fresh install due to null $wp_customize
- Extending the WP_Widget_Text class
- How to remove all the items under “Personal Options” on user profile page?
- Show message from backend
- Can I integrate wordpress with my current website so I can utilize the wordpress plugins?
- How can style text like this in wordpress
- WordPress in a Subdirectory
- How to add captcha to publish widget
- javascript file not working in a plugin template file
- If Term Name Exists, Append a Unique ID to Slug
- How can I display both LTR and RTL language texts on the same page?
- A specific menu inside a page, load different contents without reloading it, under the same link
- Widget area for individual posts (custom post type)?
- If user is logged-in display/hide widgets ( siteorigine) [closed]
- Dockerized WordPress is having Nginx Proxy Issues
- Highlight specific user with custom field value
- How to define a static Home page
- let users add multiple divs in static page
- Multiple Taxonomies Using Custom SQL Query
- Applying my own css classes in wp_menus 3?