Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle radio event when iCheck-helper is used?

I want to handle the radio button on change event. But, as the designer has already used iCheck-helper, the actual radio actions are not performed when the code is run.

Below is the code

<div class="radio-wrap">
   <input type="radio" id="bg-effect" value="full" />Full Image
</div>

When we run the code and inspect the code in chrome, the generated HTML is as below.

<div class="radio-wrap">
  <div class="iradio_minimal-grey checked"><input type="radio" id="bg-effect" value="full" checked="" style="position: absolute; opacity: 0;"><ins class="iCheck-helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; border: 0px; opacity: 0; background: rgb(255, 255, 255);"></ins></div>Full Image
</div>

To capture the selected value, I want to handle the change event for this radio button.

like image 867
KiranD Avatar asked Aug 29 '14 05:08

KiranD


2 Answers

According to documentation, you can use ifChanged event like this:

$('#bg-effect').on('ifChanged', function(event){
    alert(event.type + ' callback');
});
like image 159
Ilya Luzyanin Avatar answered Sep 20 '22 02:09

Ilya Luzyanin


I ran throught the same problem,later i found useful fix as has been correctly answered from github forum : read from this thread

The following was a fix:

$('input').on('ifCreated ifClicked ifChanged ifChecked ifUnchecked ifDisabled ifEnabled ifDestroyed check ', function(event){                
                    if(event.type ==="ifChecked"){
                        $(this).trigger('click');  
                        $('input').iCheck('update');
                    }
                    if(event.type ==="ifUnchecked"){
                        $(this).trigger('click');  
                        $('input').iCheck('update');
                    }       
                    if(event.type ==="ifDisabled"){
                        console.log($(this).attr('id')+'dis');  
                        $('input').iCheck('update');
                    }                                
                }).iCheck({
                    checkboxClass: 'icheckbox_minimal-green',
                    radioClass: 'iradio_minimal-green'
                        //increaseArea: '20%'
                });
like image 34
Ansy Avatar answered Sep 22 '22 02:09

Ansy