我有这个应用程序我正在实现新版本的popCalendar.js,并且我添加了zulu时间和日期函数。我不确定我的错在哪里。我一直在撞墙撞墙。控制台给了我这个:
Uncaught TypeError: Object #<Object> has no method 'popCalendar'
现在页面是使用python模板库生成的,这是创建日历的代码段:
class DateField(TextField):
"""
A field with a date widget as the input (which provides a browseable way to select the date)
"""
properties = TextField.properties.copy()
Base.addChildProperties(properties, Display.Label, 'calendarTypeLabel')
properties['isZulu'] = {'action':'setIsZulu', 'type':'bool'}
properties['hideTypeLabel'] = {'action':'formatDisplay.call', 'name':'hide', 'type':'bool'}
properties['dateFormat'] = {'action':'classAttribute'}
def __init__(self, id, name=None, parent=None):
TextField.__init__(self, id, name, parent)
self.userInput.style['width'] = '7.5em'
self.dateFormat = "dd-mmm-yyyy"
layout = self.addChildElement(Layout.Horizontal())
layout.addClass("FieldDescription")
self.calendarLink = layout.addChildElement(Display.Image(id + "CalendarLink"))
self.calendarLink.addClass('Clickable')
self.calendarLink.addClass('hidePrint')
self.calendarLink.setValue('images/calendar_icon.gif')
self.calendarLink.addJavascriptEvent('onclick', CallBack(self, "jsOpenCalendar"))
self.calendarTypeLabel = layout.addChildElement(Display.Label())
self.calendarTypeLabel.style['margin-left'] = "4px;"
self.calendarTypeLabel.style['margin-right'] = "4px;"
self.calendarTypeLabel.style['display'] = "block;"
self.setIsZulu(False)
self.formatDisplay = layout.addChildElement(Display.Label())
self.connect('beforeToHtml', None, self, '__updateDisplay__')
def setIsZulu(self, isZulu):
"""
If set to true the calender will use the zulu date
"""
self.isZulu = isZulu
if isZulu:
self.calendarTypeLabel.setText("Z")
else:
self.calendarTypeLabel.setText("LCL")
def __updateDisplay__(self):
if not self.editable():
self.calendarLink.hide()
self.formatDisplay.setText(self.dateFormat)
def jsOpenCalendar(self):
"""
Returns the javascript that will open the calender clientside
"""
if self.isZulu:
calendarType = "zulu"
else:
calendarType = "lcl"
return ("%sCalendar.popCalendar(this, '%s', '%s')" %
(calendarType, self.userInput.fullId(), self.dateFormat))
Factory.addProduct(DateField)
这是我一直在研究的popCalendar.js:
最后这里是我的应用程序中的HTML示例:
<img src="images/calendar_icon.gif" style="float:left;" name="dateCalendarLink" value="images/calendar_icon.gif" class="Clickable hidePrint WEBlock" onclick="zuluCalendar.popCalendar(this, 'date', 'dd-mmm-yyyy')" id="dateCalendarLink" />
答案 0 :(得分:0)
我明白了:)我只需要zuluCalendar.show()
代替zuluCalendar.popCalendar()
,就像这样:
<img src="images/calendar_icon.gif" style="float:left;" name="dateCalendarLink" value="images/calendar_icon.gif" class="Clickable hidePrint WEBlock" onclick="zuluCalendar.show(this, 'date', 'dd-mmm-yyyy')" id="dateCalendarLink" />