2011-02-03 22 views
0

我在這裏找到了這個偉大的jqueryui buttonset腳本在stackoverflow。這是爲了複選框,我需要單選按鈕。與JqueryUI的單選按鈕集 - 更改選擇

這裏:http://jsbin.com/eyonu5

基本上我希望它做的是交換基於當前選擇的圖標。現在它只基於點擊單選按鈕來交換圖標。

任何幫助,非常感謝。

感謝

回答

0

這可能不是不寫這個...... 最有效的方式,但它的工作原理The edit on your jsbin link


var noIcon = {primary: null, secondary: null} 
var withIcon = {primary: 'ui-icon-custom-tick', secondary: null}; 

$('input[name="mainautoresize"]:radio').change(function() { 
    if($('input:not(:has(:radio:checked))')) { 
     $('input:not(:has(:radio:checked))').button("option", "icons", noIcon).button('refresh'); 
    } 

    if($('input:radio:checked')) { 
     $(this).button("option", "icons", withIcon).button('refresh'); 
    } 
}); 

$('#mainautoresize').buttonset();​