I searched extensively and checked various suggestions but do not find a reasonable solution for my question: how to check if CDN versions have loaded correctly? This should include checking for css, e.g.
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" />
Any suggestions on how to check for correctly loaded css file?
Setup: Node.js running locally and on heroku.
my testing file (not working correctly):
<!DOCTYPE html>
<html> <head>
<meta charset="utf-8">
<title>template.html</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" />
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<!--<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>-->
<script>
if(typeof jQuery == 'undefined') {
document.write('<link rel="stylesheet" href="/jqm/jquery.mobile-1.3.2.min.css" \/>')
document.write('<script src="/jq/jquery-1.10.2.min.js"><\/script>')
document.write('<script src="/jq/jquery-migrate-1.2.1.min.js"><\/script>')
}
if($.mobile == undefined) {document.write('<script src="/jqm/jquery.mobile-1.3.2.min.js"><\/script>')}
</script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>data-role="header"</h1>
</div>
<div data-role="content">
<p>data-role="content"</p>
</div>
<div data-role="footer" data-position="fixed">
<h4>data-role="footer" data-position="fixed"</h4>
</div>
</div>
</body> </html>
The my test 'hello-world' web.js is below (run locally as node s/web.js
, s
is for server dir):
var express = require("express");
var path = require('path');//http://stackoverflow.com/questions/10434001/static-files-with-express-js
var app = express();
process.env.PWD = process.cwd();//http://stackoverflow.com/questions/17212624/deploy-nodejs-on-heroku-fails-serving-static-files-located-in-subfolders
app.use(express.logger());
app.use(express.static(path.join(process.env.PWD, 'html'))); //http://stackoverflow.com/questions/14576644/whats-the-simplest-way-to-serve-static-files-using-node-js
app.use(express.static(path.join(process.env.PWD, 'jq')));
app.use(express.static(path.join(process.env.PWD, 'jqm')));
//app.get('/', function(request, response) {
// response.send('Hello jc138691');
//});
var port = process.env.PORT || 3000;
app.listen(port, function() {
console.log("Listening on " + port);
});
This also does not work locally on windows: process.env.PWD = process.cwd()
does not return correct dir.
So in the nutshell, does anyone have a reasonable setup example for: node-backend and any type of front-end (e.g. jquery mobile)? Including flexible directory structure (i.e. not everything in one dir).