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?

asked Jun 7, 2017 at 15:28
1
  • Could you please tell 'which theme you are using???' I have read that it is also depends on the theme we are using. Commented 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;
 }
answered Jun 12, 2017 at 18:21
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
TomazicM
27.3k25 gold badges33 silver badges43 bronze badges
answered Apr 18, 2019 at 10:23

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.