更改 Lift/Scala 中某些 CalendarItem 项目的背景
我正在尝试使用 Lift 和 CalendarMonthView 小部件来构建 预约系统。
CalendarMonthView 与 Lift 配合得很好,但我有一个问题 无法更改显示在日历上的某些日历项的样式 日历。
根据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"}]
};
我还覆盖了 CalendarMonthView 附带的原始 style.css 并将其放在 WEB-INF/classes/toserv/calendars/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,所以我错过了什么吗?
I'm trying use Lift and CalendarMonthView widget to build a
appointment system.
CalendarMonthView works with Lift very well, but I have a problem that
could not change the style of some CalendarItem that displayed on the
calendar.
According to the API document, I use the following code to change the
css class of certain CalendarItem when build the calendar.
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)
}
}
And I've confirmed that in the output HTML, calitem2 has a "cssClass"
attribute set to "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"}]
};
And I also override the original style.css come with CalendarMonthView
and put it under WEB-INF/classes/toserv/calendars/monthview.
I've browse it and make sure that it my modified version, which add
the following "greenItem" CSS classes.
.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;
}
But when I browse my calendar page, the second CalendarItem is still
in red background, seems the CSS class is not working.
I'm not familiar with JavaScript and JQuery, so do I miss something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,我发现这是由日历小部件模块中的错误引起的。
所以我提交了一张票并在跟踪器上创建了一个补丁。
https://www.assembla.com/spaces/liftweb/tickets/563
OK, I found it is caused by a bug in Calendar widget module.
So I've file a ticket and created a patch on the tracker.
https://www.assembla.com/spaces/liftweb/tickets/563