views:

24

answers:

1
$(function () {
    function f1() {
        if (this.checked) {
            $('select[name=two]').removeAttr('disabled');
        } else {
            $('select[name=two]').attr('disabled', true);
        }
    }
    $('input[name=one]').change(f1).triggerHandler('change');
    $('.reset').click(function () {
        $('input[name=one]').removeAttr('checked').end().click(f1);
    })
});

... almost works. Please check fiddle here.

But the problem is:

  1. Check 'one' and select 'two' from dropdown.
  2. Click 'reset'.
  3. Check 'one' again and try selecting 'two' from dropdown.

Dropdown gets disabled automatically!

Many thanks for your help!

+2  A: 

You should rather trigger the change handler during reset. Replace

$('input[name=one]').removeAttr('checked').end().click(f1);

by

$('input[name=one]').removeAttr('checked').triggerHandler('change');

Here's a new fork.

BalusC
PERFECT. thanks! :)
Nimbuz
You're welcome.
BalusC