(function ($, document, apiClient) { function deleteTimer(page, id) { Dashboard.confirm("Are you sure you wish to cancel this recording?", "Confirm Recording Cancellation", function (result) { if (result) { Dashboard.showLoadingMsg(); ApiClient.cancelLiveTvTimer(id).done(function () { Dashboard.alert('Recording cancelled.'); reload(page); }); } }); } function renderTimers(page, timers) { var html = ''; html += ''; var elem = $('#items', page).html(html).trigger('create'); $('.btnDeleteTimer', elem).on('click', function () { var id = this.getAttribute('data-timerid'); deleteTimer(page, id); }); Dashboard.hideLoadingMsg(); } function reload(page) { Dashboard.showLoadingMsg(); apiClient.getLiveTvTimers().done(function (result) { renderTimers(page, result.Items); }); } $(document).on('pagebeforeshow', "#liveTvTimersPage", function () { var page = this; reload(page); }); })(jQuery, document, ApiClient);