簡體   English   中英

SyntaxError:與coffeescript和turbolinks意外比較

[英]SyntaxError: unexpected COMPARE with coffeescript and turbolinks

我正在通過這個例子:

http://road2ruby.blogspot.com/2013/01/jquery-full-calendar-with-rails3.html

當我運行服務器並嘗試轉到/ events URL時,出現以下錯誤:

ExecJS::RuntimeError at /events
SyntaxError: unexpected COMPARE
  (in /Users/rabdelaz/swap/app/assets/javascripts/calendar.js.coffee)

錯誤指向我的application.js的這一行:

<%= javascript_include_tag "application", "data-turbolinks-track" => true %>

這是我的整個application.js

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><%= content_for?(:title) ? yield(:title) : "Swap" %></title>
    <meta name="description" content="<%= content_for?(:description) ? yield(:description) : "Swap" %>">
    <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
    <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
    <%= csrf_meta_tags %>
  </head>
  <body>
    <header>
      <%= render 'layouts/navigation' %>
    </header>
    <main role="main">
       <%= render 'layouts/messages' %>
       <%= yield %>
    </main>
  </body>
</html>

我不確定此錯誤的確切含義或原因。 我對javascript和coffeescript很陌生。

$(document).ready ->  
  $('#calendar').fullCalendar  
   editable: true,  
   header:  
    left: 'prev,next today',  
    center: 'title',  
    right: 'month,agendaWeek,agendaDay'  
   defaultView: 'month',  
   height: 500,  
   slotMinutes: 30,  
   eventSources: [{  
    url: '/events',  
   }],  
   timeFormat: 'h:mm t{ - h:mm t} ',  
   dragOpacity: "0.5"  
   eventDrop: (event, dayDelta, minuteDelta, allDay, revertFunc) ->  
    updateEvent(event);  
   eventResize: (event, dayDelta, minuteDelta, revertFunc) ->  
    updateEvent(event);  
  <br/>  
 updateEvent = (the_event) ->  
  $.update "/events/" + the_event.id,  
   event:  
    title: the_event.title,  
    starts_at: "" + the_event.start,  
    ends_at: "" + the_event.end,  
    description: the_event.description      

您不小心從本教程中選擇了一些格式-在第20行中,有一個<br>標記,該標記不是有效的CoffeeScript。 刪除它應該可以解決問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM