jquery - Select2 doesn't work when embedded in a bootstrap modal -


when use select2 (input) in bootstrap modal, can't type it. it's disabled? outside modal select2 works fine.

enter image description here

working example: http://jsfiddle.net/byjy8/1/ code:

<!-- modal --> <div id="mymodal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="mymodallabel" aria-hidden="true">   <div class="modal-header">     <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>     <h3 id="mymodallabel">panel</h3>   </div>   <div class="modal-body" style="max-height: 800px">   <form class="form-horizontal">  <!-- text input--> <div class="control-group">   <label class="control-label" for="vdn_number">numer</label>   <div class="controls">      <!-- seleect2 -->     <input name="vdn_number" type="hidden" id="vdn_number"  class="input-large" required=""  />   </div> </div>    </div>   <div class="modal-footer">     <button class="btn" data-dismiss="modal" aria-hidden="true">close</button>     <button class="btn btn-primary">save changes</button>   </div> </div> 

adn js

$("#vdn_number").select2({     placeholder: "00000",     minimuminputlength: 2,     ajax: {         url: "getajaxdata/",         datatype: 'json',         type: "post",         data: function (term, page) {             return {                 q: term, // search term                 col: 'vdn'             };         },         results: function (data) { // parse results format expected select2.             // since using custom formatting functions not need alter remote json data             return {results: data};         }     } }); 

answers:

here can find quick fix

and here 'the right way': select2 doesn't work when embedded in bootstrap modal

ok, i've got work.

change

<div id="mymodal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="mymodallabel" aria-hidden="true">   <div class="modal-header">     <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>     <h3 id="mymodallabel">panel</h3>   </div>   <div class="modal-body" style="max-height: 800px"> 

to

<div id="mymodal" class="modal hide fade" role="dialog" aria-labelledby="mymodallabel" aria-hidden="true">   <div class="modal-header">     <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>     <h3 id="mymodallabel">panel</h3>   </div>   <div class="modal-body" style="max-height: 800px"> 

(remove tabindex="-1" modal)


Comments

Popular posts from this blog

design - Custom Styling Qt Quick Controls -

Unable to remove the www from url on https using .htaccess -