如何使JQuery UI部分工作?

时间:2010-07-17 03:56:58

标签: ruby-on-rails jquery-ui jquery-ui-tabs

我是JQuery的初学者(以及一般的javascript),但我正在努力。

简单设置:布局包含视图,其中包含简单的JQuery选项卡,就像http://jqueryui.com/demos/tabs/default.html

我在布局头中有以下haml:

%head
  = javascript_include_tag "jquery", "ui/jquery.ui.core", "ui/jquery.ui.widget", "ui/jquery.ui.tabs"
  = stylesheet_link_tag "global", "profiles", "forms", "smoothness/jquery-ui-1.8.2.custom", :cache => true
  :javascript
    $(function() {
      $("#tabs").tabs();
    });

我的new.html.haml视图中有以下haml:

#tabs{:class=>"ui-tabs ui-widget ui-widget-content ui-corner-all"}
  %ul{:class=>"ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all"}
    %li
      %a{:href => "#tabs-1"}
        %div{:class=>"ui-tabs-panel ui-widget-content ui-corner-bottom"} New User
    %li
      %a{:href => "#tabs-2"}
        %div{:class=>"ui-tabs-panel ui-widget-content ui-corner-bottom"} Existing User
  #tabs-1
    I am a new user
  #tabs-2
    I am an existing user

注意:当布局中为ALL时,此代码可以正常工作。但是当我将第二块代码从我的布局移动到我的视图中时,它就会停止工作。

我认为视图是外部的,但在功能上与它们的布局相同。为了让这些标签正常工作,我到底需要做些什么?谢谢!

1 个答案:

答案 0 :(得分:0)

应该没有区别。确保使用= yield替换第二个块的确切内容。检查两种方案中生成的HTML。当第二个块移动到视图时,只有空格应该不同。