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
- Is there a flowchart for WordPress loading sequence?
- How do you get formatted content of a post using the WordPress API?
- Seamless integration between WordPress and BBpress
- How to remove Profile Picture section or the message “You can change your profile picture on Gravatar.”
- Infinite-Scroll Plugin and Jetpack Infinite Scroll Plugin – Adding to “Thoughts” Theme
- WordPress equivalent to Drupal Views? [closed]
- Posting as different users
- Custom URL going to 404
- Suggestions for Implementing a Wedding Website in WordPress?
- Get ORIGINAL image links from get_post_gallery
- Why does my widget break other widgets?
- Custom Search on Custom Page while preserving the main search function
- How can I run a custom shortcode function on a live site and only run if the viewer is a specific machine?
- If the image variable is specified, show image, if not no code
- Replacing words in WordPress or theme (not in content)
- Many Rewrite Parameters/Rules
- Adding other links on header than LinkedIn, Facebook, Youtube etc
- kitchen sink not working
- Is it possible to auto sharing post on social network from specifc categories or tags
- wp_insert_post custom taxonomy multiple Category not added
- How to have differents sites share the same tables of DB?
- How to add particular attribute of product in shop as well as home page
- Duplicate Header and Footer
- Smarter Document Management links between three WordPress sites sought
- data retrieval presents last set of data
- Accountless password generation
- Create a google friendly header with text and logo
- Disallow “contributors” to edit their own posts once they’ve been set to “Pending Review”
- What are the downsides of using bootstrap in plugin development?
- show_admin_bar filter not called inside plugin class
- Custom fields in the billing address section woocommerce
- Querying a meta field on a custom taxonomy archive