javascript - How to prevent a bootstrap modal from closing when user selects item from dropdown-menu -


In an example below, when the user clicks on an item from the dropdown list, then switch off the modal window automatically Is trigerred when the user clicks the click button then the modal window will close.

  $ ('.' Dropdown menu)  

I tried to stop that behavior

'). Click (function (event) {event.stopPropagation ();});

, but it does not change anything.

  & lt; Div class = "modal fade" & gt; & Lt; Div class = "modal-dialog" & gt; & Lt; Div class = "modal-content" & gt; & Lt; Div class = "modal-body" & gt; & Lt; Form role = "form" & gt; & Lt; Div class = "row" & gt; & Lt; Div class = "col-xs-12" & gt; & Lt; Div class = "dropdown" & gt; & Lt; Button id = "dLabel" type = "button" data-toggle = "dropdown" aria-haspopup = "true" aria-expanded = "false" & gt; Select category & lt; Span class = "caret" & gt; & Lt; / Time & gt; & Lt; / Button & gt; & Lt; Ul class = "dropdown-menu" role = "menu" aria-labelbedby = "dLabel" & gt; & Lt; Li & gt; & Lt; A href = "" & gt; Category 1 & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "" & gt; Category 2 & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "" & gt; Category 3 & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "" & gt; Category 4 & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "" & gt; Category 5 & lt; / A & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div class = "row" & gt; & Lt; Div class = "col-xs-12" & gt; & Lt; Div class = "form-group" & gt; & Lt; Label = "message-text" class = "control-label" & gt; MESSAGE & lt; / Label & gt; Labels for & Lt; Textarea class = "form-control" id = "message-text" & gt; & Lt; / Textarea & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Form & gt; & Lt; Div class = "row" & gt; & Lt; Div class = "col-xs-2" & gt; & Lt; P & gt; & Lt; One class = "btn btn-primary" href = "#" role = "button" & gt; SEND & lt; / A & gt; & Lt; / P & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt;  href  

You can enter a value of href Using the link without '#' or any other value added.

  & lt; Ul class = "dropdown-menu" role = "menu" & gt; & Lt; Li & gt; & Lt; A href = "#" & gt; Action & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "#" & gt; Another Action & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "#" & gt; Here's something else & lt; / A & gt; & Lt; / Li & gt; & Lt; Li class = "divider" & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "#" & gt; Separate links & lt; / A & gt; & Lt; / Li & gt; & Lt; / Ul & gt;  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -