I have a question with Twitter Bootstrap, I'm using the Dropdown plugin and I'm trying to create a tag selector, I created an example in this link:
/
I've tried this:
event.stopPropagation;
return false;
Does anyone have a better solution that does not close the dropdown when selecting a tag?
Note: Click on "New Tag".
Thanks!
I have a question with Twitter Bootstrap, I'm using the Dropdown plugin and I'm trying to create a tag selector, I created an example in this link:
http://jsfiddle/gatnc/
I've tried this:
event.stopPropagation;
return false;
Does anyone have a better solution that does not close the dropdown when selecting a tag?
Note: Click on "New Tag".
Thanks!
Share Improve this question edited Apr 3, 2012 at 22:56 Andres I Perez 75.4k21 gold badges159 silver badges139 bronze badges asked Apr 3, 2012 at 21:52 Caio TarifaCaio Tarifa 6,04312 gold badges49 silver badges75 bronze badges2 Answers
Reset to default 3This works:
$('.dropdown-menu').on('click', 'li', function(event){...});
Updated jsFiddle
The problem with "live" it's bound to the document. This means the close event won't get intercepted by stopPropagation. If you're using jQuery 1.7.1, you can swap out "live" for "on", like so:
$('.dropdown-menu li').on('click', function(event) {
That'll bind the event to the element, and then things like stopPropagation will work.