0

This seems like a simple issue but it is frustrating me. I want to be able to click multiple items in a dropdown list that contains checkboxes without collapsing the list. I've tried a variety of event handlers on the ul, li, and a elements with no luck. These include e.preventDefault(), e.stopPropogation(), and preventing the closing of the ul through the 'hide.bs.dropdown' event as per this answer.

My list items:

<li class="serviceListItem">
  <a class="serviceListItemLink">
    <input class="checkService" type="checkbox" value="">
  </a>
</li>

and my current set of event handlers. I've tried most combinations of these.

$('#serviceDropdown').on('hide.bs.dropdown', function() {
  return false;
});

$('.serviceListItemLink').click(function(e) {
  console.log('you clicked a service');
  e.stopPropogation();
  e.preventDefault();
});
$('.serviceListItem').click(function(e) {
  e.stopPropogation();
  e.preventDefault();
});

I should add my UL has the #servicesDropdown ID. Thanks for all your help in advance SO.

Community
  • 1
  • 1
awimley
  • 692
  • 1
  • 9
  • 29
  • Can you share a jsfiddle for the issue? – darkknight Mar 18 '15 at 20:51
  • I will if the issue persists after I check out [bootstrap dropdown enhancements](https://github.com/behigh/bootstrap_dropdowns_enhancement) – awimley Mar 18 '15 at 21:10
  • It turns out, though I was spelling propagation wring, that the 'noclose' class from the dropdown enhancements was exactly what I was looking for. – awimley Mar 19 '15 at 13:07

1 Answers1

1

Is that the code you have tried? In that case, you have misspelled "propagation".

It should be:

e.stopPropagation();

...and not:

e.stopPropogation();
Pierre Wahlgren
  • 875
  • 7
  • 15
  • This is exactly what I'm trying to accomplish, but using e.stopPropogation() on just the checkbox item does nothing. Perhaps this is because three elements are being clicked when you click a checkbox: the a, li, and input. I have tried using e.stopPropogation on all of these elements together but to no avail. – awimley Mar 18 '15 at 21:08