Brainstorm's snippets (1/247)

  Enable/Disable buttons based on HTML page status

<body class="dirty ..." >

    <style>
        a.button-save, a.button-cancel { opacity: 0.5; pointer-events: none; }
        body.dirty a.button-save, body.dirty a.button-cancel { opacity: 1.0; pointer-events: auto; }
        ...
    </style>

    ...

    <div id="toolbar1" class="toolbar">
        <a href="#" class="button-save btn btn-success">Salva</a>
        <a href="#" class="button-cancel btn btn-default">Annulla</a>
    </div>

To enable buttons:

$('body').addClass('dirty');

To disable buttons:

$('body').removeClass('dirty');