WordPress.org

Support

Support » Plugins and Hacks » Hacks » Question: how to one widget when another is saved/added?

Question: how to one widget when another is saved/added?

  • Hi there,

    Summary:
    Is there a way to update widget A when widget B is modified/added/removed?

    Details:
    I’ve create an “alias” widget that outputs the content of any other active widget. In the admin, this widget has a drop-down <select> element that has an option for every other active widget. I would like the <select> menu to update when another widget is added/removed, and am not sure how to achieve this. In case this is unclear, here’s an example:

    Save I have one alias widget and two other widgets: one text and one calendar. So the <select> in the alias widget shows:
    – text-1
    – calendar-1

    Say I then drag a new pages widget into the sidebar. As soon as the widget is added, i would like the <select> in my alias widget to auto-update to the following:
    – text-1
    – calendar-1
    – pages-1

    Same goes for deleting the widget or moving it to an inactive sidebar – I would like the <select> to then auto update back to:
    – text-1
    – calendar-1

    Is there a simple way to make this happen? Is it an ajax solution? Seems to me that I need to trigger the update function in my alias widget class whenever another widget is updated – does that sound right? If so, what filter/actions might I be looking for?

    Thanks a ton, ya’ll – appreciate the help!
    – Mickey

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    @bcworkz

    I don’t have access to my server right now to double check this, but I believe you do not use PHP at all. It is all client javascript or jQuery. Thus no filters/actions to use, only DOM events.

    Whenever some widget event happens, you need your drop down’s content updated at the client. Since the widget changes get registered, when your widget loads with the next request, it will gather the updated data and display the correct state.

Viewing 1 replies (of 1 total)
  • The topic ‘Question: how to one widget when another is saved/added?’ is closed to new replies.
Skip to toolbar