2015-04-01 33 views
0

我有一個包含一些計時數據的視圖。 我正在運行一個JavaScript定時器函數,它可以計算出啓動和停止事件之間的精確秒數。如何更新計時器功能返回的時間值Kendo Mobile UI

我希望以經過的秒數更新我的視圖,並將此時間同步到記錄存儲爲offilineData。

我的視圖模板是這樣的:

<!-- TaskTime Template --> 
<script id="taskTimeTemplate" type="text/x-kendo-template"> 
    # var eSecs = ElapsedSeconds # 
    # ElapsedTime = (eSecs/3600).toFixed() +'h'+ ('0'+eSecs % 60).slice(-2)+'m'; # 
    <h2 id="#:Guid#"><i class="icon-time"></i> #: Description #</h2> 
    <ul data-role="listview" data-style="inset" style="font-size:90%;">    
    <p>Project ID: #: ParentId #</p> 
    <p>TaskID #:Id#</p> 
    <p>Time spent to date: #: ElapsedSeconds #</p> 
    </ul> 
</script> 

我的定時器功能運行和停止通過此:

$(document).ready(function(){ 
    /* Start button */ 
    $('#start').click(function(e){ 
     $('#timerButtonGroup').attr('data-index', 1); 
     startTime = new Date().getTime(); 
     timer(); 
     closeSheet(); 
    }); 
    /* Stop button */ 
    $('#stop').click(function(e){ 
     $('#timerButtonGroup').attr('data-index', 2); 
     endTime = new Date().getTime(); 
     tElapsedTime = (endTime - startTime)/1000; 
     clearTimeout(t); 
     closeSheet(); 
    }); 
}); 

我有點新的劍道移動UI和我在一個頭緒將我從計時器獲得的時間與我需要更新的記錄聯繫起來。

回答

0

試一下:

$(document).ready(function(){ 
    /* Start button */ 
    $('#start').click(function(e){ 
     $('#timerButtonGroup').attr('data-index', 1); 
     window.tmp.startTime = new Date().getTime(); 
     timer(); 
     closeSheet(); 
    }); 
    /* Stop button */ 
    $('#stop').click(function(e){ 
     $('#timerButtonGroup').attr('data-index', 2); 
     endTime = new Date().getTime(); 
     tElapsedTime = (endTime - window.tmp.startTime)/1000; 
     clearTimeout(t); 
     closeSheet(); 
     console.log(endTime); 
    }); 
}); 
+0

謝謝傳奇。 我確實對計時器部分確定。 tElapsedTime正在制定正確。我現在的目標是發送(或綁定)Kendo視圖/模板中的值,以便我可以將sync()同步到localDataStore。不幸的是,劍道文檔是由劍道團隊編寫的,並不擅長解釋使用案例。 (他們確實需要僱用技術文檔人員)。 無論如何,這是我遇到的問題;如何將該函數產生的時間綁定到Kendo視圖中的時間。也許我應該改述我最初的問題並重新發布? – 2015-04-02 08:21:21