jquery - Listen to localstorage change event -


is there way add change event listener browser localstorage items.

i have standalone app makes changes localstorage want backbone view listen , accordingly perform actions.

i couldn't find on internet except way in jquery:

$(window).bind('storage', function (e) {     console.log(e.originalevent.key, e.originalevent.newvalue); }); 

jquery can bind storage event (in exact way wrote), there few things must note:

  1. you must run code behind real ip/domain (you can read more my explanation here)
  2. the storage event fire on every open tab except current tab (which mean - if have 1 open tab, , make change local-storage in tab - will not fire). more information here.

regarding backbone - try this:

var someview = backbone.view.extend({     initialize:function() {         $(window).on("storage", this.handlelocalstoragechange)     } }); 

Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -