我試圖讓jQuery的引導程序.popover在.js提交事件中工作,但沒有任何反應,我點擊了我的表單上的提交按鈕。我正在更改輸入字段的「rel」屬性,以便當用戶單擊提交按鈕時,會將彈出窗口添加到該字段。如果我在頁面加載前設置rel屬性的常規方式,popover就會出現。如何讓twitter bootstrap.popover在.submit事件中工作
這裏的輸入字段:
<label class="control-label" for="input-name" id="input_name_label">Name *</label>
<div class="controls">
<input rel="" data-original-title="Title" data-content="Random Text" type="text" class="span3" name="name" id="input-name">
</div>
,這裏是jQuery的功能:
<script>
$("#project_form").submit(function(e) {
for(i=0;i< $("label").length;i++){
var str=$("label").eq(i).text();
if(str.charAt(str.length-1)=="*"){
$("label").eq(i).attr('rel','popover');
console.log($("label").get(i));
e.preventDefault();
$('input[rel="popover"]').popover('show');
}
console.log(str.charAt(str.length-1));
}
$("#preferences").val($("#sortable").sortable('toArray'));
});
</script>
函數發現標籤有*作爲最後一個字符應該到酥料餅的事件分配給他們。謝謝你的幫助。
不幸的是,當我嘗試的時候沒有任何變化。 –
你可以發佈[小提琴](http://jsfiddle.net/)嗎?它也支持twitter bootstrap! –
出於某種原因,我現在無法在Chrome或Firefox上訪問小提琴站點。 –