jQuery UI选项卡:片段标识符不匹配 [英] jQuery UI Tabs: Mismatching fragment identifier

查看:93
本文介绍了jQuery UI选项卡:片段标识符不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用jQuery(UI),Haml和Rails创建约会计划程序.接下来的四个星期,我将制作一组标签.

I'm trying to create an appointment scheduler using jQuery (UI), Haml, and Rails. I'm making a set of tabs for the next 4 weeks.

#schedule
  %ul
    - @schedule.each_index do |i|
      %li
        %a{:href => "#schedule-#{i}"} #{@schedule[i][:week_range]}
  - @schedule.each_index do |i|
    %div{:id => "#schedule-#{i}"}
      %p test

理想情况下,这将创建一组选项卡,例如(12月27日至1月Nth)作为选项卡标题,然后在每个框中进行测试".

Ideally, this would create a set of tabs such as (December 27th-January Nth) as the tab title and then have "test" in each box.

在applications.js中,我有:

In applications.js I have:

$('#schedule').tabs();

但是,这无法正确显示,当我单击选项卡时,它在JavaScript控制台中显示了此错误:

However, this doesn't render properly and when I click on a tab it gives me this error in the javascript console:

jQuery UI Tabs: Mismatching fragment identifier.

我正在使用最新的jQuery和jQuery UI版本.

I'm using the latest jQuery and jQuery UI releases.

有人可以告诉我我在做什么错吗?

Can anyone tell me what I'm doing wrong?

这是相应的HTML的样子:

This is what the corresponding HTML looks like:

<div id='schedule'>
    <ul>
        <li>
            <a href='#schedule-0'> December 27 - January 2</a>
        </li>
        <li>
            <a href='#schedule-1'> January 3 - January 9</a>
        </li>
        <li>
            <a href='#schedule-2'> January 10 - January 16</a>
        </li>
        <li>
            <a href='#schedule-3'> January 17 - January 23</a>
        </li>
    </ul>
    <div id='#schedule-0'>
        <p>test</p>
    </div>
    <div id='#schedule-1'>
        <p>test</p>
    </div>
    <div id='#schedule-2'>
        <p>test</p>
    </div>
    <div id='#schedule-3'>
        <p>test</p>
    </div>
</div>

推荐答案

在生成的HTML中,您的id中不应包含#.将%div{:id => "#schedule-#{i}"}更改为%div{:id => "schedule-#{i}"}

Your ids should not have a # in them in the generated HTML. Change %div{:id => "#schedule-#{i}"} to %div{:id => "schedule-#{i}"}

这篇关于jQuery UI选项卡:片段标识符不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆