title: Close Bootstrap Dropdown after link click
body: <p>I have a bootstrap dropdown menu below.  It has a link in it hooked up to a knockout.js binding, that returns false because I don't want the # tag to be sent to the browser URL.  However, doing this doesn't close the dropdown menu when I click the link.  Any way around this?</p>
  <p><strong>HTML</strong></p>
  <pre><code>&lt;div class=&quot;btn-group&quot;&gt;
      &lt;button class=&quot;btn dropdown-toggle&quot; data-toggle=&quot;dropdown&quot; data-bind=&quot;enable: !noResults()&quot;&gt;&lt;i class=&quot;icon-download-alt&quot; &gt;&lt;/i&gt; Export &lt;span class=&quot;icon-caret-down&quot;&gt;&lt;/span&gt;&lt;/button&gt;
  
      &lt;ul class=&quot;dropdown-menu&quot;&gt;
          @foreach(var exportUrl in Model.ExportUrls)
          {
              &lt;li&gt;
                  &lt;a href=&quot;#&quot; data-bind=&quot;disable: noResults(), download: { url: '@exportUrl.Value', data: data }&quot;&gt;&lt;img src=&quot;/Content/less/images/img/@(exportUrl.Key.ToString().ToLower()).png&quot; alt=&quot;@exportUrl.Key.GetDisplayName()&quot;/&gt; @exportUrl.Key.GetDisplayName()&lt;/a&gt;
              &lt;/li&gt;
          }
      &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  <p><strong>knockut.js binding</strong></p>
  <pre><code>ko.bindingHandlers.download = {
      init: function (element, valueAccessor) {
  
          var value = ko.utils.unwrapObservable(valueAccessor()),
              id = 'download-iframe-container',
              iframe;
  
          $(element).unbind('click').bind('click', function () {
  
              iframe = document.getElementById(id);
  
              if (!iframe) {
                  iframe = document.createElement(&quot;iframe&quot;);
                  iframe.id = id;
                  iframe.style.display = &quot;none&quot;;
              }
  
              if (value.data) {
                  iframe.src = value.url + (value.url.indexOf('?') &gt; 0 ? '&amp;' : '?') + $.param(ko.mapping.toJS(value.data));
              } else {
                  iframe.src = value.url;
              }
  
              document.body.appendChild(iframe);
  
              return false;
          });
      }
  };
  </code></pre>