bootstrap modal problem in WAB

1586
10
06-05-2018 09:54 AM
scottmiller10
New Contributor II

I am having a problem with the bootstrap modal as well. The open modal budget is on the widget, but when I click nothing happens. I've tried using the <a href...> as well the bootstrap button with data-toggle, but neither works. I attached the widget and html files below.

0 Kudos
10 Replies
Adri2cPérez_Beneito
Occasional Contributor

Hi!

I kindly recommend using the Dialog Dijit class. In this way you avoid overloading your application with external dependencies..

Best

RobertScheitlin__GISP
MVP Emeritus

Scott,

   So there are many issues in your code.

  1. You do not add script tags and stylesheets inside the widget.html. You are treating the widgets html template like it was a whole html app and not just a markup template as it is suppose to be.
  2. Your define array order is mixed up.  dojo/domReady! is Always the last item in the array.  Because you have it as the 4th from last your Legend and LayerInfos classes is not defined properly.
  3. You are trying to do A LOT of your coding inside the postCreate. While this is allowed you might reconsider the widgets life cycle and determine if postCreate is the most appropriate location for all of that.
  4. I would not even be considering using BootStrap modal. WAB and dojo has options for dialogs and modal so why convolute your code with Another 3rd party library?
0 Kudos
scottmiller10
New Contributor II

Robert,

Where should I put onClick functions if not in postCreate? By no means do I fully understand the structure of these widgets, so I appreciate your feedback greatly. The only reason I'm using bootstrap is to make my app look a little more phone-friendly. 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Scott,

 postCreate function will be OK if you want the map click handler added as soon as the widget is created. Many time I will wait for the user to activate a button or the widget to be opened before adding an event like this. A more significant issue is that the map click handler is not removed once your widget is closed.

0 Kudos
scottmiller10
New Contributor II

Robert, 

Is there any way I could have an onClick that zooms in 10%? I can't find any function in the API to zoom by %.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Scott,

  this.map.extent.expand(1.1); zooms in 10%

https://developers.arcgis.com/javascript/3/jsapi/extent-amd.html#expand 

Expands the extent by the factor given. For example, a value of 1.5 will be 50% bigger.
scottmiller10
New Contributor II

on(this.zoomIn, "click", lang.hitch(this, function(){
this.map.extent.expand(1.1);
}));

this didn't work but doesn't throw any errors. Am i using this wrong?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Scott,

Sorry Use.

this.map.setExtent(this.map.extent.expand(1.1));
0 Kudos
scottmiller10
New Contributor II

Hey Robert, 

For some reason that isn't working either. Is there anything else i could do with map.getZoom and map.setZoom?

0 Kudos