0

我有这个应用程序,我正在实现新版本的 popCalendar.js,并且我添加了 zulu 时间和日期功能。我不确定我在这里有什么问题。我一直在用头撞墙。控制台给了我这个:

未捕获的类型错误:对象 # 没有方法“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:

http://snipt.org/AfNh5

最后是我的应用程序中的 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" />
4

1 回答 1

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" />
于 2013-08-16T16:33:13.183 回答