New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncaught TypeError: Cannot read property 'appendChild' of null #11
Comments
Is there a chance the HTML page for the client doesn't have a body element? |
Yeah, I'm using "ng-view" (AngularJS), so basically everything is being dynamically added |
Hm, so are you saying there isn't a body element? If not, can you add one? Or delay the client's initialization to when the body becomes available? The only instance of Line 371 in 06b3d83
|
ill try the delay |
I tried that still get the same error |
I mean delaying the initialization of var delay = 2000;
var url = 'https://mysite.com/something/myapp?my.tabName=01rf0000000D4nF#!/dashboard';
setTimeout(function() {
var storage = new CrossStorageClient(url);
var setKeys = function() {
return storage.set('newUserData', 'foo', 9000)
.then(function() {
return storage.get('key2', 'bar');
});
};
storage.onConnect()
.then(setKeys)
.then(function() {
return storage.get('key1');
}).then(function(res) {
console.log(res); // 'foo'
})['catch'](function(err) {
console.log(err);
});
}, delay); Presumably, there'd be some sort of promise, hook, or callback that would indicate that the body is loaded. If not, you could poll, which is a bit less ideal: var bodyLoaded = new Promise(function(resolve, reject) {
var pollDelay = 100;
var poll = setInterval(function() {
if (!window.document.body) return;
clearInterval(poll);
resolve();
}, pollDelay);
});
bodyLoaded().then(function() {
var url = 'https://mysite.com/something/myapp?my.tabName=01rf0000000D4nF#!/dashboard';
var storage = new CrossStorageClient(url);
var setKeys = function() {
return storage.set('newUserData', 'foo', 9000)
.then(function() {
return storage.get('key2', 'bar');
});
};
storage.onConnect()
.then(setKeys)
.then(function() {
return storage.get('key1');
}).then(function(res) {
console.log(res); // 'foo'
})['catch'](function(err) {
console.log(err);
});
}); |
thanks i figured it out i was calling the crossStorage function before i even defined angularjs, but it works as expected. Thanks for your help!! |
np! Glad it worked :) |
putting my code into jquery |
I dont know what I'm doing wrong I followed the example and I'm getting :
On the Hub I put :
And for the Client I put:
Its not showing the last bit of code but I got it right from the example
The text was updated successfully, but these errors were encountered: