Select to view content in your preferred language

Programmatically close Widget on Click - WAB DE

2202
7
Jump to solution
02-06-2018 03:54 PM
JeffWilcox1
Occasional Contributor

Attempting to use custom code in the Smart Editor widget, so that save button has an onclick that closes the editor entirely (instead of bringing it back to template) after save and would greatly appreciate a little direction on where it might go (not terribly familiar with JS), I am working in the Smart Editor Widget.js file and tried pasting in

PanelManager.getInstance().closePanel(widgetid + ‘_panel’);

I included the Define and the Function, but it inst working where I've been placing it. Have I botched the syntax?

Does anyone have a sample I could refer to?

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Jeff,

   That sounds like PanelManager is null in your codes scope. So where is the PanelManager var created?

View solution in original post

0 Kudos
7 Replies
RobertScheitlin__GISP
MVP Emeritus

Jeff,


  Do you have a local variable called widgetid? That’s probably your issue if not.

0 Kudos
JeffWilcox1
Occasional Contributor

I think i have isolated the piece of code in the Widget.js that needs to be modified

this.own(on(saveButton, "click", lang.hitch(this, function () {
 if (!this._validateFeatureChanged()) {
 this._resetEditingVariables();
 return;
 }
if (this.map.infoWindow.isShowing) {
 this.map.infoWindow.hide();
 }
 this._saveEdit(this.currentFeature);‍‍‍‍‍‍‍‍‍

I am currently using the widgetID from the WebApp's config.json file i have added the following line after line 9:

PanelManager.closePanel(widgets_SmartEditor_Widget_22 + '_panel');‍‍

Nothing happens (except a browser developer tool error pops up saying PanelManager.closePanel is not a function)

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Jeff,

   That sounds like PanelManager is null in your codes scope. So where is the PanelManager var created?

0 Kudos
JeffWilcox1
Occasional Contributor

I was able to get this to work with your insightful response! I had neglected to create the variables

Am I going about this the wrong way? I'm attempting to close the edit widget and end the editing session. the window closes...but i'm still in edit mode for all intents and purposes (ie: anything i click becomes selected for editing, instead of InfoWindow loading.)

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Jeff,

   I think you have to call the widgets close method. I will look into this.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Jeff,

   Strange it took a little fiddling.

        this.own(on(saveButton, "click", lang.hitch(this, function () {
          if (!this._validateFeatureChanged()) {
            this._resetEditingVariables();
            return;
          }

          if (this.map.infoWindow.isShowing) {
            this.map.infoWindow.hide();
          }
          this._saveEdit(this.currentFeature);
          setTimeout(lang.hitch(this, function(){
            PanelManager.getInstance().closePanel(this.id + '_panel');
            this._cancelEditingFeature(true);
          }), 300);
        })));
JeffWilcox1
Occasional Contributor

this is awesome, closing and infowindow selection work flawlessly.

the widget is nonfunctional after save/closing though (after the initial save, editing a point results in an unending loadscreen). i'll keep tinkering with these functions and see if i can find one that resets the panel. 

0 Kudos