Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap typeahead not Working inside the Bootstrap Modal

I am using codeigniter framework and i am using bootstrap typeahead and all is fine but my problem is when i put it inside the bootstrap modal the bootstrap typeahead will not work. can someone help me? please. this is my code

<a data-target="ajaxify" data-toggle="modal" href="<?php echo base_url()?>task/add_task" class="no-u quick-task">
    <h4>Task</h4>
    <span>This is a simple description</span>
 </a>

and inside my add_task controller i call the view task_view.php and task.js but it seems that the typeahead is not working inside the bootstrap modal.

this is the content of task.js

$(document).ready(function(){
$("#assign_to").typeahead({
    source: [{value: 'Charlie'}, {value: 'Gudbergur'}]              
});
});

this is the content of task_view.php : just a sample.

<div id="ajaxx" class="modal hide fade">
<div class="modal-header">
  <a class="close" data-dismiss="modal">&times;</a>
  <!--Your title here -->
  <h3>Modal Heading</h3>

</div>
<div class="modal-body">
<form><input type="text" name="assign_to" id="assign_to" /></form>
</div>
<div class="modal-footer">
  <!--Your dont change the attributes only the value here -->
  <a href="#" id="n0" class="btn n0" data-dismiss="modal">Close</a>
  <a href="#" id="y1" class="btn btn-primary y1" data-submit="modal">Save</a>
</div>
like image 731
user1342825 Avatar asked Apr 19 '12 02:04

user1342825


2 Answers

I'm using in my custom css following

.modal-body{overflow-y: inherit;}

.modal-open .dropdown-menu {
  z-index: 2050;
}

working example of use

like image 187
Mike Castro Demaria Avatar answered Oct 16 '22 03:10

Mike Castro Demaria


make sure to remove typeahead-append-to-body="true"

https://github.com/angular-ui/bootstrap/issues/3262

like image 23
James Salamon Avatar answered Oct 16 '22 03:10

James Salamon