mercredi 22 juin 2016

Nested if in coffeescript

I need to have these conditions in a coffeescript file of my rails app:

if window.location.href == "website.com/rooms"
  if $(".panel-heading")[0].id == data["room"] &&
    $('.messages').append data['message']
    $("div#" + data["room"]).find("#status").text(data["status"])
else
  $('.messages').append data['message']
  $("#wrapper").scrollTop($("#wrapper")[0].scrollHeight)

However, I get an error for the nested if: unexpected if

How can I use nested if statements in coffeescript ?

In JS, I could do this:

if(condition){
  if(condition){

  }
}
else{

}

Aucun commentaire:

Enregistrer un commentaire