2012-04-01 71 views
0

我的應用程序中有一個引導程序下拉菜單,效果很好,除了當我單擊任何輸入字段時,下拉菜單會淡出。我知道javascript函數$('.dropdown-menu').find('form').click(function (e) { e.stopPropagation(); });,但在我的情況下,它似乎沒有做任何事情。Bootstrap Dropdown with Form Insider

這裏是我的代碼:

%li.dropdown 
      %a.dropdown-toggle{"data-toggle" => "dropdown", :href => "#"} 
      Sign In 
      %span.caret 
      .dropdown-menu 
      %form{"accept-charset" => "UTF-8", :action => "/users", :method => "post", :style => "margin: 0px"} 
       %div{:style => "margin:0;padding:0;display:inline"} 
       %input{:name => "utf8", :type => "hidden", :value => "✓"}/ 
       %input{:name => "authenticity_token", :type => "hidden", :value => "4L/A2ZMYkhTD3IiNDMTuB/fhPRvyCNGEsaZocUUpw40="}/ 
       %fieldset.textbox{:style => "padding:10px"} 
       %input{:placeholder => "Username", :style => "margin-top: 8px", :type => "text"}/ 
       %input{:placeholder => "Passsword", :style => "margin-top: 8px", :type => "password"}/ 
       .divider 
       %input.btn-primary{:name => "commit", :type => "submit", :value => "Log In"}/ 

誰能請我的錯誤點?爲什麼這不起作用?感謝提前。

回答

0

試試這個:

$('.dropdown input, .dropdown label').click(function(e) { 
    e.stopPropagation(); 
}); 
+0

謝謝!我很感激它,它工作完美! – 2012-04-16 06:41:33