最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin6浏览0评论

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.

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.

Share Improve this question asked Aug 29, 2014 at 5:14 KiranDKiranD 4513 gold badges7 silver badges20 bronze badges 1
  • Have you tried the solution? Did it work? If not, could you add some comments? – Ilya Luzyanin Commented Sep 1, 2014 at 8:28
Add a comment  | 

2 Answers 2

Reset to default 17

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

$('#bg-effect').on('ifChanged', function(event){
    alert(event.type + ' callback');
});

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%'
                });
发布评论

评论列表(0)

  1. 暂无评论