2010-06-24 70 views
3

我試圖使用Lift和CalendarMonthView小部件來構建 預約系統。在Lift/Scala中更改某些CalendarItem項目的背景

CalendarMonthView適用於Lift很好,但我有一個問題, 無法更改 日曆上顯示的某些CalendarItem的樣式。

根據API文檔,在構建日曆時,我使用以下代碼更改某些CalendarItem的css類 。

class MySnippet { 
    def test (xhtml: NodeSeq) = { 
     val c = Calendar.getInstance 
     val meta = MonthViewMeta (Calendar.SUNDAY, Locale.getDefault) 

     c.set (2010, 0, 0) 

     bind ("cal", xhtml, 
       "widget" -> CalendarMonthView (c, meta, cals, Empty, 
              Empty, Empty)) 
    } 

    def cals = { 
     val c1 = Calendar.getInstance 
     val c2 = Calendar.getInstance 

     c1.set (2010, 0, 5, 10, 0) 
     c2.set (2010, 0, 6, 10, 0) 

     val calitem1 = CalendarItem ("4", c1, CalendarType.MEETING). 
         optional (
          _.subject  ("Red Item"), 
          _.description ("Background should be read") 
         ) 

     val calitem2 = CalendarItem ("5", c2, CalendarType.MEETING). 
         optional (
          _.subject  ("Green Item"), 
          _.description ("Background should be green"), 
          _.baseCSSClassName ("greenItem") 
         ) 


     List (calitem1, calitem2) 
    } 

} 

而且我已經證實,在輸出HTML,calitem2有着 「的CssClass」 屬性設置爲 「greenItem」。

var calendars = { 
    "items": [{"id": "4", "start": 20, "end": 48, 
       "weekDay": "3", "startTime": "10:0",    
       "subject": "Red Item", "month": 0, "dayOfMonth": 5,    
       "description": "Background should be read"}, 
       {"id": "5", "start": 20, "end": 48, "weekDay": "4", 
       "startTime": "10:0", "subject": "Green Item", "month": 0, 
       "dayOfMonth": 6, "description": "Background should be green", 
       "cssClass": "greenItem"}] 
};    

而且我也覆蓋掉原有的style.css配備CalendarMonthView 並把它放在WEB-INF /班/ toserv /日曆/ monthview。

我已經瀏覽了它並確保它是我的修改版本,它添加了 下面的「greenItem」CSS類。

.greenItem { 
     margin: 1px; 

} 

.greenItem a { 
     margin-left: 1px; 
     color: #FFFFFF; 
     text-decoration: none; 
     background-color: #00FF00; 
     display: block; 

} 

.greenItem a:hover { 
     text-decoration: none; 
     background-color: #ff6655; 
     display: block; 

} 

.greenItemHead { 
     margin: 1px; 

} 

.greenItemHead a { 
     margin-left: 1px; 
     color: #FFFFFF; 
     text-decoration: none; 
     background-color: #00FF00; 
     display: block; 

} 

.greenItemHead a:hover { 
     text-decoration: none; 
     background-color: #ff6655; 
     display: block; 

} 

.greenItemBody { 
     margin: 1px; 

} 

.greenItemBody a { 
     margin-left: 1px; 
     color: #FFFFFF; 
     text-decoration: none; 
     background-color: #00FF00; 
     display: block; 

} 

.greenItemBody a:hover { 
     text-decoration: none; 
     background-color: #ff6655; 
     display: block; 
} 

但是,當我瀏覽我的日曆頁,第二CalendarItem仍 在紅色的背景,似乎CSS類是行不通的。

我對JavaScript和JQuery不熟悉,所以我錯過了什麼?

回答

相關問題