最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Twitter Bootstrap Dropdown with Tags Selector - Stack Overflow

programmeradmin0浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论