0
使用jQuery移動1.4.5,我試圖把可摺疊集的標題欄,像這樣內部的按鈕:添加按鈕collapsibleset頭
<div data-role="collapsibleset" data-content-theme="a" data-iconpos="left" id="street_listing" class="ui-collapsible-set ui-group-theme-inherit ui-corner-all">
<div data-role="collapsible" class="ui-collapsible ui-collapsible-inset ui-corner-all ui-collapsible-themed-content ui-first-child ui-last-child ui-collapsible-collapsed">
<h3 id="street_name" class="ui-collapsible-heading ui-collapsible-heading-collapsed">
<a href="#" class="ui-collapsible-heading-toggle ui-btn ui-btn-icon-left ui-btn-inherit ui-icon-plus">Street name
<a href="#remove_street_button" class="ui-btn ui-btn-inline remove_street" street="street" id="remove_street">Remove</a>
<span class="ui-collapsible-heading-status"> click to expand contents</span>
</a>
</h3>
</div>
</div>
的問題是,點擊按鈕沒有按」 t註冊。它只打開並關閉標題欄。下面是我想單擊該按鈕時觸發功能:
$(function() {
$(document).on('click', ".remove_from_group", (function() {
//do stuff
}))
});
複雜的問題是collapsibleset獲得通過Ajax調用動態插入到頁面。
嗯,點擊仍然沒有爲我註冊。點擊它只是展開/摺疊它們的身體。我的代碼和你的代碼唯一的區別是可摺疊的設置頭和按鈕在ajax調用之後被注入頁面。不知道爲什麼會有所作爲。當它不在標題中時,我的按鈕可以正常工作。奇怪的。我會繼續尋找。 謝謝。 – StevieD
我可以將一段javascript代碼的onclick()位直接放到span標記中,並且正在註冊。很奇怪。 – StevieD
是的,所以把它扔到'span'標籤中就是了: 'onclick =「\ $(function(){var section = \ $('#remove_street_street_id')。closest('。ui-collapsible') ;'' 不知道爲什麼在標題中的'