mardi 14 juillet 2015

Jquery Calx2 with hidden elements

I am building a form which uses jQuery Calx 2.2.3.js to do some on the fly calculations.

The problem I am having is that I have some selections which have dependencies on other selections.

So what I have a is a range of checkboxes (A, B, C, D) when checkbox (C) is checked it makes another checkbox (E), and three radio buttons visible (F, G, H), and when checkbox (C) is unchecked checkbox (E), and radio buttons (F, G, H) are unchecked, disabled, and hidden.

The triggered checkbox, and radio buttons are made to appear, disabled, hidden using jQuery.

What is happening is the calx2 calculations are working, when checkbox (C) is checked, but if checkbox (E) is selected, then checkbox (C) is deselected the sum for checkbox (E) stays apparent, even though the state is unchecked/disabled/hidden. The only way it works is if checkbox (E) is manually unchecked!!

Here is my jQuery...

    $('input[id^="switch_"]').change(function () {
            $('#action_' + this.id.replace('switch_', '')).toggle("slide", this.checked);
        }).change();
        $(function () {
            $('form').each(function () {
                var form = $(this);
                form.find('.roof').change(function () {
                    if (form.find('.roof:checked').length) {
                        form.find('.antenna, .sunroof').button("enable");
                    } else {
                        form.find('.antenna, .sunroof')
                                .removeAttr('checked')
                                .button("refresh")
                                .button("disable", "disable");
                    }
                });
            });
        });
        $().calx('registerFunction', 'CXPRICE', function (data) {
            var price = data.split('|')[2];
            return price;
        });

});
        $(document).ready(function() {
                $('#form1').calx();
        });

I know this is going to be something simple for you jQuery geniuses out there, but to a mere mortal still on the lower end of the learning curve, this is driving me nuts!!

Thanks for any help! Si




Aucun commentaire:

Enregistrer un commentaire