1

I am using offline.js (0.7.18) and its working fine, when I go on/offline the indicator changes state, all good so far.

I can also see on Offline JS Simulate UI, that a login panel is having its style toggled between display:block and display:none when on/offline is triggered. But I can't discover how this works.

I want to hide a 'Submit' button when offline is triggered.

  • Here's a [link](http://stackoverflow.com/tags/offline.js/info) to the docs. I think what you want is: Offline.state: The current state of the connection 'up' or 'down' – Mickers Nov 01 '16 at 19:18

1 Answers1

1

You can use the sample from the Offline JS Simulate UI page that uses jQuery:

<script>
    $(function(){

        var 
            $online = $('.online'),
            $offline = $('.offline');

        Offline.on('confirmed-down', function () {
            $online.fadeOut(function () {
                $offline.fadeIn();
            });
        });

        Offline.on('confirmed-up', function () {
            $offline.fadeOut(function () {
                $online.fadeIn();
            });
        });

    });
</script>

Give the class "online" to any element you want shown when the system is online and give the class "offline" to any element you want shown when the system is offline.

<button class="online">ABC</button>
NineBerry
  • 26,306
  • 3
  • 62
  • 93