HubSpot / offline

Automatically display online/offline indication to your users
http://github.hubspot.com/offline/docs/welcome
MIT License
8.64k stars 846 forks source link

Help with turbolinks #6

Open arkmediastudio opened 11 years ago

arkmediastudio commented 11 years ago

Hi

can you please help to get offline work with turbolinks https://github.com/rails/turbolinks/. when i use turbolinks to fetch pages there is no offline-ui class in body tag. i know this could be a problem with how turbolinks work, but is there any work around to get it working.

Thanks

adisuryadi commented 11 years ago

You might be interested on viewing this lines of code: https://github.com/HubSpot/offline/blob/master/js/ui.js#L141

I don't know how turbolinks actually works in details, but i also have issue with the rendering the UI and events because currently I'm injecting the script on-fly and the DOMContentLoaded off course not being triggered.

adamschwartz commented 11 years ago

@zackbloom perhaps we could simply expose Offline.init so that it can be initialized manually. @adisuryadi that would have solved your issue, correct?

zackbloom commented 11 years ago

That's not really going to help unfortunately, the init which happens in Offline.init will bind XHR, but not much else.

adisuryadi commented 11 years ago

@adamschwartz for my problem I changed offline.js to be loaded via bower instead, so then brunch build it with other assets and run on init. Works like charm, i need to manually added the main prop on bower.json override though:

"offline": {
   "main": [
     "offline.min.js",
     "./themes/offline-theme-default.css"
   ]
 }

because brunch need it for picking the main files to build.

adamschwartz commented 11 years ago

@zackbloom @adisuryadi should we make that the default bower.json configuration?

andyhennie commented 11 years ago

Anyone got this to work?

jeffblake commented 9 years ago

+1... it would be great to expose a method initialize Offline.js manually, so that it can be used with Turbolinks. Otherwise, turbolinks replaces the Offline.js dom elements on page change.

tonywok commented 8 years ago

That or allow users to allow init to bind to custom events. For example, with turbolinks, you'd want to bind to turbolinks:load instead of DOMContentLoaded. In the interim, you can make this change yourself.