2014-10-30 73 views
1

我正在與Kalendae https://github.com/ChiperSoft/Kalendae合作,我必須說它非常出色,無需考慮依賴關係也很棒。Kalendae js:有沒有辦法在日期選擇後自動關閉日曆?

默認行爲是在選中文本框時彈出,並更新日期,但這需要我點擊關閉[x]按鈕關閉日曆。

我希望日曆在選擇日期後關閉。我確認這是Demo頁面上的默認行爲:http://chipersoft.com/Kalendae/

+0

看起來Kalendae提供了一些我可以訂閱的活動。我可能不得不朝那個方向看。 – 2014-10-30 21:36:01

+0

看看:https://github.com/ChiperSoft/Kalendae/issues/29 – yunandtidus 2014-10-30 23:19:17

+0

謝謝yunandtidus,幫助,我結束了這樣做https://github.com/ChiperSoft/Kalendae/issues/29#issuecomment -61990192 – 2014-11-06 14:57:21

回答

0

下面的代碼爲我工作(不幸的是,它依賴於jQuery的,所以一定要確保你已經包括jQuery的):

ku = Kalendae.util; 
$.each($('.kalendae .k-in-month'), function(index, value) { 
    ku.addEvent(value, 'click', function(event){ 

     this.style.display="none"; 
    }); 
}) 

一個jQuery實現對我不夠好,如果你想這樣做的純JavaScript你需要替換使用$ .each並使用純javascript方法選擇.kalendae元素。

+0

對於我的用例,我實際上必須將代碼嵌入到window.onload調用中。 window.onload = function(){ /*這裏的自定義代碼*/ }; – 2014-11-06 16:34:11