user2513846
user2513846

Reputation: 1236

enable/disable input field depending on checkbox status

I have a problem disabling an input field when a checkbox is checked with a plugin called iCheck (http://fronteed.com/iCheck/).

Note: my code is working when the iCheck plugin is not used.

Working example without iCheck: http://jsbin.com/gusewu/1/

NOT working example when iCheck is included: http://jsbin.com/ludiqi/1/

Any help on debugging this would be appreciated. I've been on this for 2 days now. :-/

Upvotes: 0

Views: 668

Answers (2)

dfsq
dfsq

Reputation: 193301

You should make use of ifChanged custom event:

$('input').iCheck({
    checkboxClass: 'icheckbox_flat-blue',
    radioClass: 'iradio_flat'
})
.on('ifChanged', function() {
    $('#upload_image:input').prop('disabled', this.checked);
})
.trigger('ifChanged');

Demo: http://jsbin.com/neheqocilu/2/edit

Upvotes: 1

Flash Thunder
Flash Thunder

Reputation: 12045

You're doing it wrong... iCheck overrided all those events and has own ones, all listed here

$('input').on('ifChecked', function(event){
  alert(event.type + ' callback');
});

Upvotes: 1

Related Questions