2013-10-09 78 views
1

我的Express Web應用程序的Jade文件中有一些JQuery,但似乎沒有任何東西被調用。這裏的內容玉文件:JQuery不使用Jade

extends layout 
block content 
    p Landing page 
    #info Info area 
block foot 
    a(href="https://localhost:8888/logout", title="logout") Logout 

這裏的佈局玉文件:

!!!5 
html 
    head 
     title #{title} 
     link(rel='stylesheet', href='/stylesheets/style.css') 
     script(type='text/javascript', src="http://code.jquery.com/jquery-1.9.1.min.js") 
     script(type='text/javascript', src="/idle-timer.js") 
     script(type='text/javascript'). 
      $(document).ready(function() { 
       $(document).idleTimer(10000); 
       $(document).on("idle.idleTimer", function(){ 
        console.log("alert"); 
       }); 

       $(#info).click(function(){ 
        $(this).hide(); 
       }); 
      }); 
    body 
     header 
      h1 Web App Sample 
     .container 
      .main-content 
       block content 
      .sidebar 
       block sidebar 
     footer 
      block foot 

任何人都可以看到的問題可能是什麼?也許縮進?

+1

'腳本(類型=「文/ JavaScript的」)' - 這是否點在該行的末尾做什麼?可能會更容易將您的JS添加到外部文件中,並像調用'idle-timer.js'一樣調用它。 – Andy

+0

這個圓點顯然是必需的,因爲當我不添加它時,我在控制檯中得到這個警告,「implicit textOnly for'script'和'style'已被棄用,請使用'script.'或'style.'。 – gjw80

+2

嘗試在源代碼中檢查生成的代碼,如果您獲得正確的html。此外,你錯過了添加qoutations''('#信息')' – Drew

回答

1

很難看到我的手機,但你縮進你的腳本代碼,如:。

html 
    head 
     script(src='jsfile') 
     script 
      $(document).ready 
    body #same level as head! 
     header