I constantly have to hold this in the temp variable in order to access it in other functions. For example, in the two methods below, I hold this in the that variable:
startTimer: function () { var that = this; if ($('#defaultCountdown:hidden')) $('#defaultCountdown').show('slow'); shortly = new Date(); shortly.setSeconds(shortly.getSeconds() + 5); $('#defaultCountdown').countdown('change', { until: shortly, layout: '<ul id="errorList"><li>Next update in <b>{snn}</b> {desc}</li></ul>', description: 'seconds', onExpiry: function () { that.performUpdate(); } }); }, performUpdate: function () { var that = this; this.message.fetch({ success: function () { $('#calleesStatuses').html(''); that.callees.refresh(that.message.get("Callees")); $('#defaultCountdown').hide('slow'); that.startTimer(); }, error: function (request, settings) { that.killCountDown(); showErrorMessage(request.responseText) } }); },
Anyway, or can I use apply ?
source share