【问题标题】:Jquery ui tabs with jadeJquery ui 标签与玉
【发布时间】:2013-02-19 21:00:29
【问题描述】:

您好,我正在尝试使用 Jade 模板引擎为节点 js 创建 Jquery UI 选项卡。而且它不工作。

这里是 index.jade:

#tabs
  ul
    li
      a(href='#tabs-1') New employee
    li
      a(href='#tabs-2') Index of employees

  #tabs-1
    .page-header
      h1 New employee

    - var form = formFor(employee, {action: pathTo.employees(), method: 'POST', id: "employee_form", class: 'form-horizontal'})

    != form.begin()
    include _form
    .form-actions
      != form.submit('<i class="icon-ok icon-white"></i>  Create employee', {class: 'btn btn-primary'})
      span= ' or '
      != linkTo('Cancel', pathTo.employees(), {class: 'btn'})
    != form.end()

  #tabs-2
    .page-header
      h1 Index of employees


    - if (employees.length) {
    .row
      .span12
         table.table.table-striped
           thead
             tr
               th ID
               th.span3 Actions
           tbody
             - employees.forEach(function (employee) {
             tr
               td
                 != linkTo('employee #' + employee.id, path_to.employee(employee))
               td
                 != linkTo('<i class="icon-edit"></i> Edit', pathTo.edit_employee(employee), {class: 'btn btn-mini'}) + ' '
                 != linkTo('<i class="icon-remove icon-white"></i> Delete', pathTo.employee(employee), {class: 'btn btn-mini btn-danger', method: 'delete', remote: true, jsonp: '(function (u) {location.href = u;})'})
             - });
    - } else{
    .row
      .span12
         p.alert.alert-block.alert-info
            strong No employees were found.
    - }

这是我的 layout.jade

!!! 5
html
  head
    title= title
    != stylesheetLinkTag('http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/themes/base/jquery-ui.css', 'bootstrap', 'application', 'bootstrap-responsive')
    != javascriptIncludeTag('http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.js', 'https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js', 'rails', 'application')
    script
      $(document).ready(function() {
        alert("hi");
        $("#tabs").tabs();
      });
    != csrfMetaTag()
  body
    .navbar
        .navbar-inner
            .container
               a.brand(href='#') Project name

    .container
      - var flash = request.flash('info').pop(); if (flash) {
        .alert.alert-info= flash
      - }

      - flash = request.flash('error').pop(); if (flash) {
        .alert.alert-error= flash
      - }

      != body

      hr
      footer
        p © Company 2012
  != contentFor('javascripts')

选项卡未呈现。

呈现的 html 位于:http://jsfiddle.net/DUUdr/5/

但这不适用于玉

【问题讨论】:

    标签: javascript jquery jquery-ui node.js pug


    【解决方案1】:
    1. 您的页面上没有有效的 JQuery UI 选项卡布局(在模板中)
    2. 您的页面上没有 ID 为 tabs 的容器
    3. 你的 JS 有错误 - 你试图警告未定义的变量 hi

    official documentation 中寻找工作示例。

    【讨论】:

      【解决方案2】:

      您错过了&lt;div id="tabs"&gt; 内的&lt;ul&gt; 标签,用于标签页标题.. 标签可以正常工作..

      试试这个

      <div id="tabs">
      <ul>
        <li><a href="#tabs-1">New employee</a></li>
        <li><a href="#tabs-2">Index of employees</a></li>
      </ul>
      <div id="tabs-1">
       ......
      

      我对翡翠不太了解..但是结构应该是这样,标签才能工作和ui-css样式......在翡翠结构中添加&lt;ul&gt;&lt;li&gt;....,它应该可以工作

      注意:您的小提琴中的警报中缺少 "".. 所以它不起作用

      并在 html 中添加了上面的 &lt;ul&gt;.. 并且它工作了......工作 fiddle here

      更新

      您首先加载了 jquery ui 代码,然后加载了 jquery min 第二个......这是不正确的......首先加载 jquery min 然后再加载 ui.. 也检查 fiddle.. 查看 fiddle 的源代码,你会获取结构..

        != javascriptIncludeTag('https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js','http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.js', 'rails', 'application')    
      

      【讨论】:

        【解决方案3】:

        成功了,错误出现在 jquery-min.js 和 jquery-ui.js 的位置

        在将 javascripts 链接到页面时,Jquery-min.js 应该是第一位,而 Jquery-ui.js 应该是第二位

        更新

         != javascriptIncludeTag('http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.js', 'https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js', 'rails', 'application')
        

          != javascriptIncludeTag('https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.js', 'rails', 'application')
        

        【讨论】:

        • 我啊!!!!我以为我有相同的答案..现在您发布了相同的内容并添加了您的答案.. :):).. 很酷..
        • @bipen:有 2 小时的时间间隔 :)
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-05-04
        • 1970-01-01
        • 2011-03-20
        • 2015-06-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多