1

I'm trying open a widget from other widget:

_open: function () {

    var config = WidgetManager.getInstance().appConfig.getConfigElementById("widgets_IdentifierRed_Widget");
    WidgetManager.getInstance().loadWidget(config).then(function(widget){
      WidgetManager.getInstance().openWidget(widget.id);
      console.log(widget);
    });            }

First I load it, then open it. But it doesn't work.

How can I open a widget from other widget?

1
  • Could you please tell 'which theme you are using???' I have read that it is also depends on the theme we are using. Jun 12, 2017 at 14:44

2 Answers 2

2

This function works for me:

_openPanelWidget: function (aWidgetId) {
    var def = new Deferred();
    var wm = WidgetManager.getInstance();
    var myWidget = wm.getWidgetById(aWidgetId);
    if (myWidget == null) {
      wm.appConfig.widgetPool.widgets.some(function (aWidget) {
        if (aWidget.id == aWidgetId) {
          myWidget = aWidget;
          return true;
        }
        return false;
      });
      wm.loadWidget(myWidget).then(lang.hitch(this, function (args) {
        PanelManager.getInstance().showPanel(myWidget).then(function () {
          wm.openWidget(myWidget);
          def.resolve();
        })
      }));
    } // end if
    else {
      PanelManager.getInstance().showPanel(myWidget).then(function () {
        wm.openWidget(myWidget);
        def.resolve();
      })
    } // end else
    return def;
  }
0

I would suggest as below

   var event = new MouseEvent('click', {
            view: window,
            bubbles: true,
            cancelable: true
          });
          query(".jimu-widget-onscreen-icon").forEach(lang.hitch(this,function(widgetButton){
                 if(widget.name==widgetButton.dataset.widgetName){
                      widgetButton.dispatchEvent(event);
                     }
                    }));
               }),

register

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.