0

I am using Fronteed's iCheck plugin. This code only works if the radio button changes. But, I also need it to work on page load (I have pulled the value from the database to get the current checked button). Here's my code:

$('input').on('ifChecked', function () {

    var number = this.attributes['name'].value.slice(-1);

    if ($(this).attr("id") == "icon")
    {
        $('#box_colour_' + number).show();
        $("#text_box_colour_" + number).show();
        $('#text_box_' + number).show();
        $('#box_icon_' + number).show();
        $('#box_link_' + number).show();

        $('#box_image_' + number).hide();
        $('#box_video_' + number).hide();

    }
});

Thanks

1 Answers1

0

You should use a jQuery Trigger and set a determined time to get executed.
You could try this:

$("document").ready(function() {
        setTimeout(function() {
            $("input").trigger('ifChecked');
        },10);
    });

A delay of 10ms will cause the function to run immediately, after all the $(document).ready() handlers have been called.

Original answer: https://stackoverflow.com/a/2060275/4630423 I just made some changes.

Community
  • 1
  • 1
Victor Garcia
  • 179
  • 1
  • 12