4
我有Bootstrap下拉按鈕,我想獲取數據,當用戶單擊此下拉按鈕,而不是我需要加載國家列表在頁面加載時,這裏是我的代碼;Bootstrap下拉項綁定與Ajax源
<div class="btn-group">
<input class="text-box single-line" data-val="true" data-val-required="The Country field is required." id="Country" name="Country" type="text" value="US" />
<a class="btn dropdown-toggle country" id="country" data-toggle="dropdown">
<span class="caret"></span>
</a>
<ul class="dropdown-menu countrys" role="menu" aria-labelledby="dropdownMenu">
//store country list
</ul>
</div>
我單擊下拉按鈕,就不能觸發jQuery的工作,似乎引導不允許自定義的下拉作用。
$(document).ready(function() {
$('#country').click(function() {
// Only call notifications when opening the dropdown
if (!$(this).hasClass('open')) {
$.ajax({
type: "GET",
url: "/getCountries",
async: false,
dataType: "script"
});
}
});
});
Bootstrap允許幾乎任何你能想象的東西。你是否在控制檯中發現錯誤? – isherwood 2013-03-15 16:55:28
不行,我用firefox設置了break,看來bootstrap禁用客戶端事件。 – Ericyu67 2013-03-15 18:22:52
我犯了錯誤,把這個腳本放在jquery – Ericyu67 2013-03-16 01:47:43