2013-06-18 51 views
0

我有一個複選框,ID爲#cond99;它的形式加載Ajax,這是行得通,但我想添加一個動作,它不工作。誰能幫我?Ajax複選框不會工作

jQuery = window.parent.jQuery; 
jQuery(document).ready(function() 
{  
    jQuery('input.styled').iCheck( 
    {  
     checkboxClass: 'icheckbox_minimal-orange', 
     radioClass: 'iradio_minimal-orange', 
     increaseArea: '40%' // optional 
    });  
    jQuery('input.styled').iCheck('update'); 
    jQuery("#cond999").bind("change", function() 
    { 
     jQuery('#conditions_more').toggle(); 
    }); 
}); 
+0

什麼是'iCheck'? –

+0

@JamesMontagne - http://damirfoy.com/iCheck/ – j08691

+0

iCheck是插件風格化複選框和收音機 https://github.com/damirfoy/iCheck –

回答

1

這應該工作:

jQuery(document).on('change', '#cond999', function() { 
    jQuery('#conditions_more').toggle(); 
}); 
0

如果要插入你r#cond999元素作爲Ajax,它在document.ready事件觸發時可能不可用,因此,你不能綁定任何東西。

您可能會考慮在Ajax請求的回調中綁定此事件,該請求會將複選框插入代碼中。

+0

我用.on('ifChecked',函數(事件)從iCheck庫 –