Comments (10)
I've found javascript variable:
search_order: [
// TODO: air
'localstorage',
'globalstorage',
'gears',
'cookie',
'ie',
'flash'
],
I need to use Flash, however - Flash support is BROKEN in this version of PersistJS, because of race condition (#942):
// create new swf object
swfobject.embedSWF(this.o.swf_path || cfg.path, cfg.id, cfg.size.w, cfg.size.h, '8', null, {}, cfg.params, {}, function(o) {
// save flash element
B.flash.el = o;
});
}
// use singleton flash element
this.el = B.flash.el;
B.flash.el is set async meaning that this.el = B.flash.el; gets execute before. It seems that version from http://pablotron.org/?cid=1557 works fine with Flash so I'll see if I can use that one. By the way - which one version is newer? Can we combine them somehow?
from persist-js.
Please test the latest version. The object was incorrectly set to the swfobject callback instead of the element.
from persist-js.
Nah, it's not working. I've looked into change you've made and I don't think it's possible to attach el to this like that:
// create new swf object
swfobject.embedSWF(this.o.swf_path || cfg.path, cfg.id, cfg.size.w, cfg.size.h, '8', null, {}, cfg.params, {}, function(o) {
// save flash element
B.flash.el = o.ref;
this.el = o.ref;
});
Correct me if I'm wrong, but I think this is what is needed:
var self = this;
// create new swf object
swfobject.embedSWF(this.o.swf_path || cfg.path, cfg.id, cfg.size.w, cfg.size.h, '8', null, {}, cfg.params, {}, function(o) {
// save flash element
B.flash.el = o.ref;
self.el = o.ref;
});
It seems that does the trick... dunno why initially I had trouble with get method. Did persist.swf changed from initial version (0.1.0)? This thing hosted on GitHub is newer (0.2.0)??
from persist-js.
And one more question - related to swfobject.js - is it somehow possible to embed that swf synchronously (as it was done in 0.1.0) rather than asynchronously... since this way following will fail:
var _store;
$(function() {
_store = new Persist.Store('test2', {
swf_path: 'Scripts/persists2/persist.swf'
});
var val = _store.get('pbd'); // flash store not yet initialized
});
from persist-js.
Sorry about that, I pushed too hastily last night. I've tested the latest update in Chrome, Safari, Firefox, IE6/7/8 as working. Any luck with the latest version?
from persist-js.
Your point about doing it synchronously rather than asynchronously is a good one. I don't personally use the flash backend, ever, but we could probably change the code to:
// create new swf object
swfobject.embedSWF(this.o.swf_path || cfg.path, cfg.id, cfg.size.w, cfg.size.h, '8', null, {}, cfg.params, {});
}
this.el = document[C.flash.id];
},
What do you think?
from persist-js.
Well, I must say I enjoy this conversation - it's nice to work with js pro ;)
And sorry for bothering you, but the reason why I want to force Flash usage is is because it persists between browsers - which is awesome.
Now, as for your change - I've tried number of methods and all of them failed.
- this.el = document[C.flash.id] won't work (this.el is null when called in get method)
- I've even tried modifying swfobject.js, but if I make that method sync (rather than async & embedding on DomLoad) - any call to Flash throws: Error calling method on NPObject!
So - I dunno what to do. Correction we did (var self and all that) will work for most cases - but when somebody wants to use library on page load (which happens in 90% of cases) the only way it'll work is with setTimeout after init. And as anyone will probably guess - that sucks (I've had tons of troubles with Safari on Mac during yesterday's testing - even with setTimeout(code, 1000) sometimes it works, sometimes it doesn't)
from persist-js.
OK - I've found out why it doesn't work in Safari - if tab is not focused, this.el.get is not function - it is undefined. But when you switch to tab - this.el.get for some reason gets defined as function and starts working.
Anyone has some suggestion for this problem? Because these race conditions really suck.
from persist-js.
I've went back and tested Persist 0.1.0, and this issue has existed since at least then.
I also embedded the generated flash into the page, instead of dynamically loading it, and updated persist to use the preloaded embedded flash, but the issue still exists.
I pushed a change to use createSWF instead of embedSWF, which seems to at least help with this.el being undefined. Please try the latest update and tell me if things are any better.
If you would like to upload a zip to reproduce your issue, and I will do my best to help continue debugging it.
from persist-js.
Sorry that I haven't followed up on this; for the sake of those who come over this page in future I just wanted to say that nothing can be done about this issue as it is tied to Safari and how it interacts with Flash.
Simply - if tab is not focused, this.el will be null and that's it. In all other browsers there is no problem with this.
Also, during past 3 months I've been testing persist-js in production on number of websites I administrate and it works really nice. And thanks for that bugfix on async asignment to jeremydurham - that fix was needed.
from persist-js.
Related Issues (20)
- Add .md extension
- Force backend
- #<HTMLObjectElement> has no method 'get' HOT 6
- Urgent
- Accessing the data store HOT 1
- Suggestion: Chopping up values to fit Persist.size
- Register a Bower package
- Saving association fails with many to many oracle associations
- User for...in instead of for loop in iterate function
- Listing on bower? HOT 2
- remove of an item returns this.getitem is not a function
- CDN
- Why license hasn't been included in js files? HOT 1
- firefox prevented the outdated plugin adobe flash from using in your website HOT 6
- Persist.type localStorage no longer persists across windows / tabs
- Cookie's domain is not consistent
- Clear all data from storage HOT 1
- Safari private browser mode HOT 1
- How can I use persist-js on react HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from persist-js.