Closed billmn closed 11 years ago
create a delegated function that applies your iCheck, then call it later from the AJAX callback
$(document).on('icheck', function(){
$('input[type=checkbox], input[type=radio]').iCheck({
checkboxClass: 'icheckbox_square-blue',
radioClass: 'iradio_square-blue'
});
}).trigger('icheck'); // trigger it for page load
then in your AJAX
$.ajax(...).done(function(){
// deal with your data
$(document).trigger('icheck'); // apply icheck to checkboxes
});
Of course, you can just set a global function that does that, but cluttering the global space isn't a good idea
Works fine! thank you
There is a little problem whit this delegation. If you use $('#mycheckbox').on('ifToggled', function(){ // custom function }); to bind custom function to specific checkbox after ajaxs trigger 'icheck' there is no bind function to $('#mycheckbox') Is there any solution for this?
How can I apply iCheck to checkboxes/radios loaded from ajax? In a normal HTML page works fine, but if I load this page from ajax, iCheck isn't applied.
I'm using this code :
Cheers