Project

General

Profile

« Previous | Next » 

Revision ad9b573a

Added by Benjamin Dauvergne over 11 years ago

js.dialogs: add a class .enable-on-change for buttons

If a button holds this class it will be disabled by default; only a
change to one of its form fields will activate it.

View differences:

calebasse/static/js/calebasse.dialog.js
44 44
        title: $button.attr('title') || $button.text(),
45 45
      });
46 46
    });
47

  
48
    /* Form buttons with the '.enable-on-change' class are only enabled if an
49
     * input or a select of the form is modified. */
50
    $('form button.enable-on-change, form input[type="submit"]').prop('disabled', 'true');
51
    $('form input, form select').on('change', function () {
52
      var form = $(this).closest('form');
53
      $('button.enable-on-change, form input[type="submit"]', form).enable();
54
    })
55
    $('form input').on('keyup', function () {
56
      var form = $(this).closest('form');
57
      $('button.enable-on-change, form input[type="submit"]', form).enable();
58
    })
47 59
  });
48 60
})(window.jQuery)

Also available in: Unified diff