-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
Description
Consider this code:
class jQueryCalendar
saveDate: (inputField) ->
alert 'Saving Date' + $(inputField).val()
initCalendarObjects: ->
params =
onSelect: (dateText, inst) =>
@saveDate `this`
$('.timelineCalendar').datepicker params
After running coffee -c -b on this file, the following javascript is generated:
var jQueryCalendar;
jQueryCalendar = (function() {
function jQueryCalendar() {}
jQueryCalendar.prototype.saveDate = function(inputField) {
return alert('Saving Date' + $(inputField).val());
};
jQueryCalendar.prototype.initCalendarObjects = function() {
var params,
_this = this;
params = {
onSelect: function(dateText, inst) {
return _this.saveDate(_this);
}
};
return $('.timelineCalendar').datepicker(params);
};
return jQueryCalendar;
})();
Notice that what was in backticks incorrectly replaced. "this" was replaced with "_this"
A workaround is to put a space after the backtick: this
instead of this
But it seems like this is a bug that needs to be fixed.