1
我是一個完整的初學者在jQuery(和一般的JavaScript),但我有一個去這個。如何讓JQuery UI在部分中工作?
簡單的設置:佈局包含視圖,其中包含簡單的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在佈局中。但是當我將第二塊代碼從我的佈局移到我的視圖中時,它停止工作。
我認爲視圖是外部的,但在功能上與它們的佈局相同。爲了讓這些標籤正常工作,我必須做些什麼?謝謝!
爲什麼你在問題標題中提到了一個部分,但在你的問題中沒有提到一個部分? – 2010-07-19 05:57:56
山姆,對於混淆抱歉...我的意思是區分具有一個視圖中的所有代碼,而不是將javascript放在單獨的佈局文件中。 – sscirrus 2010-07-19 22:58:59