jQuery

46 views
Skip to first unread message

klr...@gmail.com

unread,
Nov 14, 2012, 12:47:50 PM11/14/12
to zap...@googlegroups.com
I am getting "ReferenceError: jQuery is not defined"

I have 
324   require('zappajs') 3444, '87.xxx.xxx.xx',https:https_options,  ->
325      @enable 'minify', 'serve jquery', 'serve sammy', 'serve zappa'
....
337   @use 'zappa'
 338   @use 'partials'
 339   @use 'bodyParser'
 340   @use 'methodOverride'
 341   @use 'cookies'
 342   @use 'cookieParser'
 343   @use session: {secret: 'xxxxxxxxxx'}
 344   #@use @app.router  # re email stephane
 345   @use 'static'
 346   @use @express.favicon 'favicon.ico'

Is this not enough to go ahead with
$-> ...

Up to now I have not used jQuery in my little app, what else is missing?
(Trying to write a vertical ticker in a div.)

(Express 3.0, Zappa 4.10, Node 8.10)

Thanks, Karl


step...@shimaore.net

unread,
Nov 14, 2012, 1:02:05 PM11/14/12
to zap...@googlegroups.com
> Up to now I have not used jQuery in my little app, what else is missing?

You need to reference jQuery on the client side, basically have a

<script type="text/javascript" src="/zappa/jquery.js"></script>

somewhere in the HTML page you send to the browser.
S.
Message has been deleted

klr...@gmail.com

unread,
Nov 14, 2012, 2:26:44 PM11/14/12
to zap...@googlegroups.com
Well, I had it in the layout section, the font link and the meta get recognized correctly.
If I put it in the view directly it produces the same error

1468   @view layout: ->     # LAYOUT only displays body
1469     doctype 5
1470     html ->
1471       title "xxx Stock Information"
1472       base(href='https://www.xxx.net:3444/')
1473       meta charset: 'utf-8'
1474       meta name: "description", content: "xxxnd Australia Reseller Information B2B"
1475       meta name: "keywords", content: "xxx B2B"
1476       meta name: "author", content: "xxx"
1477       #meta "http-equiv": "content-type", content: "text/html;charset=UTF-8"
1478       head ->
1479         # only https!!! can't use with http, load locally if no https av
1480         link rel:'stylesheet',href: 'https://fonts.googleapis.com/css?family=Rosario', type: 'text/css'
1481         #link href: "css/ticker-style.css", rel: "stylesheet", type: "text/css"
1482         #in the browser?
1483         # run socketio before zappa.js ?
1484         script src: '/socket.io/socket.io.js'
1485         #script src: '/mootools/mootools-1.2.5-core-nc.js'
1486         #script src: '/mootools/mootools.js'
1488         script src: '/zappa/jquery.js', type: 'text/javascript'
1489         script src: 'jquery.ticker.js', type: 'text/javascript'
1490         #script src: '/index.js'


554   @view showstock1: ->    #SHOWSTOCK1SHOWSTOCK1
 555     script src: '/zappa/jquery.js', type: "text/javascript"
 556     #$ ->
 557     jQuery ->
 558      text = 'txt'

ReferenceError: jQuery is not defined
    at Object.eval (eval at <anonymous> (/home/userpt18z97/proj05/node_modules/zappajs/node_modules/coffeecup/lib/coffeecup.js:410:10))
    at eval (eval at <anonymous> (/home/userpt18z97/proj05/node_modules/zappajs/node_modules/coffeecup/lib/coffeecup.js:410:10))
    at zappa.adapter.compile (/home/userpt18z97/proj05/node_modules/zappajs/lib/zappa.js:1022:16)
    at View.zappa.adapter.renderFile [as engine] (/home/userpt18z97/proj05/node_modules/zappajs/lib/zappa.js:1037:23)
    at View.render (/home/userpt18z97/proj05/node_modules/zappajs/node_modules/express/lib/view.js:75:8)
    at Function.app.render (/home/userpt18z97/proj05/node_modules/zappajs/node_modules/express/lib/application.js:503:10)
    at ServerResponse.res.render [as partial] (/home/userpt18z97/proj05/node_modules/zappajs/node_modules/express/lib/response.js:718:7)
    at ServerResponse.module.exports.res.render (/home/userpt18z97/proj05/node_modules/zappajs-partials/index.js:55:9)
    at zappa.app.app.(anonymous function).apply.concat.render (/home/userpt18z97/proj05/node_modules/zappajs/lib/zappa.js:726:31)
    at zappa.app.app.(anonymous function).apply.concat.ctx.render (/home/userpt18z97/proj05/node_modules/zappajs/lib/zappa.js:660:40)

klr...@gmail.com

unread,
Nov 16, 2012, 10:23:02 AM11/16/12
to zap...@googlegroups.com
it also appears correctly in the browser
<head><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Rosario" type="text/css" /><script src="/socket.io/socket.io.js"></script><script src="/zappa/jquery.js" type="text/javascript"></script> ...

I have updated to node 08.14 and installed zappa 4.12 with the whole shebang and have replaced 'serve jquery' etc with @use 'zappa' but still get:

ReferenceError: jQuery is not defined
    at Object.eval (eval at <anonymous> (/home/userpt18z97/proj06/node_modules/zappajs/node_modules/coffeecup/lib/coffeecup.js:410:10))
    at eval (eval at <anonymous> (/home/userpt18z97/proj06/node_modules/zappajs/node_modules/coffeecup/lib/coffeecup.js:410:10))
    at zappa.adapter.compile (/home/userpt18z97/proj06/node_modules/zappajs/lib/zappa.js:997:16)
    at View.zappa.adapter.renderFile [as engine] (/home/userpt18z97/proj06/node_modules/zappajs/lib/zappa.js:1012:23)
    at View.render (/home/userpt18z97/proj06/node_modules/zappajs/node_modules/express/lib/view.js:75:8)
    at Function.app.render (/home/userpt18z97/proj06/node_modules/zappajs/node_modules/express/lib/application.js:505:10)
    at ServerResponse.res.render [as partial] (/home/userpt18z97/proj06/node_modules/zappajs/node_modules/express/lib/response.js:717:7)
    at ServerResponse.module.exports.res.render (/home/userpt18z97/proj06/node_modules/zappajs-partials/index.js:55:9)
    at zappa.app.app.(anonymous function).apply.concat.render (/home/userpt18z97/proj06/node_modules/zappajs/lib/zappa.js:696:31)
    at zappa.app.app.(anonymous function).apply.concat.ctx.render (/home/userpt18z97/proj06/node_modules/zappajs/lib/zappa.js:633:26)

What am I doing wrong? Must be something really stupid.

PROD$ pwd
/home/userpt18z97/proj06
PROD$ find . -print | grep jquery
./node_modules/zappajs/vendor/jquery-1.8.2.min.js
./node_modules/zappajs/node_modules/express/node_modules/connect/node_modules/qs/test/browser/jquery.js

PROD$ node -v
v0.8.14
PROD$ express --version
3.0.0rc4

PROD$ nodemon main.coffee
16 Nov 16:17:10 - [nodemon] v0.6.20
16 Nov 16:17:10 - [nodemon] watching: /home/userpt18z97/proj06
16 Nov 16:17:10 - [nodemon] starting `coffee main.coffee`
info: socket.io started
Zappa version is:  0.4.12
Express server listening on port 3444 in development mode
Zappa 0.4.12 "Freak Out!" orchestrating the show

PROD$ uname -r
3.2.0-4-amd64

Thanks for your patience, Karl
************************

klr...@gmail.com

unread,
Nov 16, 2012, 1:23:19 PM11/16/12
to zap...@googlegroups.com
found my stupid error, since one can neatly write coffeescript code in coffeekup I wrongly assumed one just calls jquery directly in the view when one has to say 
coffeescript -> ...
Reply all
Reply to author
Forward
0 new messages