javascript - Twitter Bootstrap Dropdown with Tags Selector - Stack Overflow

I have a question with Twitter Bootstrap, I'm using the Dropdown plugin and I'm trying to cre

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 badges
Add a ment  | 

2 Answers 2

Reset to default 3

This 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745570506a4633652.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信