jQuery UI - 未捕获TypeError:对象[object Object]没有方法'tabs'(在jade中)

时间:2014-02-07 06:38:28

标签: javascript jquery jquery-ui pug

似乎无法获得此翻译的HTML ...

无论如何,我查看了所有现有的答案,并确保:

  1. 语法正确
  2. 在我的脚本之前加载jQuery UI之前加载jQuery(我甚至把它放在页面的两端......)
  3. 确保jade正确编译为html
  4. 所以是的,仍然没有工作。有人有想法吗?

    代码:

    第1部分:

    link(rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css")
    script(src="//code.jquery.com/jquery-1.9.1.js")
    script(src="//code.jquery.com/ui/1.10.4/jquery-ui.js")
    

    第2部分:

    #tabs
      ul
        li 
         a(href='#tabs-1') Tab 1
        li 
         a(href='#tabs-2') Tab 2
        li 
         a(href='#tabs-3') Tab 2
        #tabs-1
        #tabs-2
        #tabs-2
    

    第3部分:

    script.
      $(function() {
         $( "#tabs" ).tabs();
    });
    

    整件事:

    doctype html
    
    html(lang='en')
    head
        meta(charset='utf-8')
        meta(http-equiv='X-UA-Compatible', content='IE=edge')
        meta(name='viewport', content='width=device-width, initial-scale=1')
        meta(name='description', content='')
        meta(name='author', content='')
        link(rel='shortcut icon', href='')
        title Starter Template for Bootstrap
    
        link(href='/css/bootstrap.min.css', rel='stylesheet')
        link(href='/css/mystyles.css', rel='stylesheet')
        link(rel='stylesheet', href='codemirror/lib/codemirror.css')
        link(rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css")
        script(src="//code.jquery.com/jquery-1.9.1.js")
        script(src="//code.jquery.com/ui/1.10.4/jquery-ui.js")
    
    
      body
       form(name='uploadDL', id='uploadDL', action = '/sendDL', method = 'post')
        .navbar.navbar-inverse.navbar-fixed-top(role='navigation')
          .container-fluid
            .navbar-header
              button.navbar-toggle(type='button', data-toggle='collapse', data-target='.navbar-collapse')
                span.sr-only Toggle navigation
                span.icon-bar
                span.icon-bar
                span.icon-bar
              a.navbar-brand(href='#') DL in JS
            .collapse.navbar-collapse
              ul.nav.navbar-nav
                  button.btn.btn-default.navbar-btn(type="submit") Run
            //
              /.nav-collapse 
        br
        .container-fluid
          .col-md-3
              textarea(name = "DLCode", id="DLcode") x=1;y=x+1;z=x+y;t=z+x;a=x+x+x;
          .col-md-9
            .canvas
              #tabs
                ul
                  li 
                    a(href='#tabs-1') Tab 1
                  li 
                    a(href='#tabs-2') Tab 2
                  li 
                    a(href='#tabs-3') Tab 2
                #tabs-1
                #tabs-2
                #tabs-2
    
    
    
           Placed at the end of the document so the pages load faster 
        script(src='codemirror/lib/codemirror.js')
        script(src='codemirror/mode/javascript/javascript.js')
        script.
          var editor = CodeMirror.fromTextArea(document.getElementById("DLcode"), {lineNumbers: true,mode: "javascript"});
    
        script(src='/js/bootstrap.min.js')
        script(src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js")
        script(src="http://mbostock.github.com/d3/d3.js")   
        script(src='/d3graph.js')
        script.
           $(uploadDL).on('submit', 'form', function(e) {
           var form = e.currentTarget;
           $.ajax({
           url: form.action,         
           type: 'POST',                                             
           data: $(form).serialize(), 
           success: function(response) {renderGraph(response);},
           error: function() {}
           });  
           e.preventDefault();
           });
        script.
          $(function() {
               $( "#tabs" ).tabs();
          });
    

1 个答案:

答案 0 :(得分:2)

confliction of jquery试试这个,

jQuery(function() {
     jQuery( "#tabs" ).tabs();
});

此外,您已将jquery包括两次,删除第二个。

script(src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js")