Created
April 16, 2013 10:23
-
-
Save rohman/5394874 to your computer and use it in GitHub Desktop.
Belajar TypeHead Bootstrap CI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>..:: Buku Tamu ::..</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<!-- Bootstrap --> | |
<link href="<?php echo $this->config->item('assets_url');?>css/bootstrap.css" rel="stylesheet" media="screen"> | |
<script type="text/javascript" src="<?php echo base_url();?>js/jquery-1.8.2.js"></script> | |
<script type="text/javascript" src="<?php echo base_url();?>js/bootstrap.js"></script> | |
<script type="text/javascript"> | |
var BASE_URL = "<?php echo base_url()?>"; | |
$(document).ready(function(){ | |
$("#searchTamu").typeahead({ | |
source: function (query, process) { | |
return $.ajax({ | |
url:BASE_URL+"tamu/searchTamu/", | |
type:"POST", | |
data:{ name: query, limit:10}, | |
dataType:"JSON", | |
success:function (data) { | |
labels = []; | |
mapped = {}; | |
$.each(data, function (i, item) { | |
mapped[item.value] = item.value; | |
labels.push(item.value); | |
}); | |
process(labels); | |
} | |
}); | |
} | |
,updater: function (item) { | |
return mapped[item]; | |
} | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<div class="container"> | |
Cari Tamu <input type="text" id="searchTamu" /> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment