I need to translate a piece of JavaScript code into CoffeeScript, here it is:
jQuery(function($) {
if (typeof ($.fn.jCarouselLite) != 'undefined') {
$("#slider_1").jCarouselLite({
btnNext: "#slider_1 .next",
btnPrev: "#slider_1 .prev",
visible: 1
});
}
The if condition is causing a problem, Here’s what I’m doing at that point:
jQuery ->
$ = jQuery
if typeof $.fn.jCarouselLite not 'undefined'
$("#slider_1").jCarouselLite
btnNext: "#slider_1 .next
btnPrev: "#slider_1 .prev"
visible: 1
But the compiler is complaining saying: PARSE ERROR ON LINE 2: UNEXPECTED ‘POST_IF’
Can anybody help me? How can correctly translate that If condition into Coffeescript?
Thanks,
notis a unary operator, so I think you meant… but you can just use
?:… but that error seems like it would be caused by funny indentation, like on line 2…