2012-04-01 7 views
0

Ich habe ein Bootstrap-Dropdown-Menü in meiner Anwendung, das funktioniert gut, außer dass, wenn ich auf eines der Eingabefelder klicken das Dropdown-Menü ausblendet. Ich weiß über die JavaScript-Funktion $('.dropdown-menu').find('form').click(function (e) { e.stopPropagation(); });, aber in meinem Fall scheint es nichts zu tun.Bootstrap Drop-Down mit Formular Insider

Hier ist mein Code:

%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"}/ 

Kann jemand an meinem Fehler hinweisen bitte? Warum funktioniert das nicht? Danke ist Fortschritt.

Antwort

0

Versuchen Sie stattdessen:

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

Thank you! Ich schätze es, es hat perfekt funktioniert! –