2013-10-11 24 views
1

我有時間場在我的數據庫:從timepicker在web2py中刪除秒?

Field('start_time','time')

它被渲染成我的形式如下:

<input type="text" value="" name="start_time" id="mytable_start_time" class="span4 time hasTimeEntry" autocomplete="off">

這將創建接受時間,如輸入框:

12:05:39

對於我的使用情況秒是不必要的我怎麼能刪除秒鐘,輸入爲:

12:05

而且我想指定12小時的時間,AM/PM,而不是24小時的時間的時間。

回答

2

web2py中使用jQuery的時間輸入插件 - 你可以瞭解如何配置它here。該插件的代碼包含在/static/js/calendar.js的底部。

您可以將其設定calendar.js加載後調整的默認值。如果您使用的是標準的layout.html,這將是web2py_ajax.html之後包括:

{{include 'web2py_ajax.html'}} 

<script> 
jQuery.timeEntry.setDefaults({show24Hours: false, showSeconds: false}); 
</script> 
+0

我看到的配置是通過JavaScript(如:'$( '#showSeconds')timeEntry({showSeconds:真});'。 )。我在哪裏/如何將它放入我的web2py代碼中?在我看來?全局改變它與改變它的一種特定形式有什麼關係? – User

1

沒有必須發表評論的能力,但在的layout.html(時間步長是可選的,但肯定是好的易!)

{{include 'web2py_ajax.html'}} 
<script> 
    jQuery.timeEntry.setDefaults({show24Hours: false, showSeconds: false, timeSteps:   [1,30,1]}); 
</script> 

而且我相信,如果你不希望它只是全球使用該視圖的佈局,而不是內部或創建另一個佈局,包括在您的視圖,而不是默認...