Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6050005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:38:24+00:00 2026-05-23T07:38:24+00:00

If i want to get a js code like this which compiles from coffeescript:

  • 0

If i want to get a js code like this which compiles from coffeescript:

  var sortableTodos = new Sortables("todo-list", {
constrain: true,
clone: true,
handle: ".todo-content",
onComplete: function(ele){
  sortableTodos.serialize(false, function(element, index){
    todo = Todos.get(element.getProperty("id").replace("todo-", ""));
    todo.save({"order": index});
  });
}
});

I can’t write coffee code like below:

sortableTodos = new Sortables(
"todo-list"
(
    constrain: true
    handle: '.todo-content'
    onComplete:(ele)->
        sortableTodos.serialize false, (element,index)->
                todo = Todos.get(element.getProperty("id")).replace("todo-","")
                todo.save("order":index)

)   
   )

but the following works(it got brackets after onComplete)

sortableTodos = new Sortables(
"todo-list"
(
    constrain: true
    handle: '.todo-content'
    onComplete:((ele)->
        sortableTodos.serialize false, (element,index)->
                todo = Todos.get(element.getProperty("id")).replace("todo-","")
                todo.save("order":index)
               )
)   
  )  

I don’t know why?Is it a bug?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:38:24+00:00Added an answer on May 23, 2026 at 7:38 am

    The CoffeeScript parser has many quirks when it comes to splitting function arguments across multiple lines. (See issue 1135.) Multi-line arguments to functions are only allowed for YAML-style objects when you omit parentheses. So while

    func
      foo: bar
      x: y
    

    works (compiling to pass a single object to func), other arguments often need to be on the same line as func. Or you can use a \ escape at the end of the line, as in JS, to make multiple lines be treated by the compiler as a single line:

    func \
      a  \
      b
    

    The best fix for your case is to move your string to the same line as the function call, ditch the parentheses around the object literal (use curly braces if you like), and be consistent with your indentation:

    sortableTodos = new Sortables("todo-list", {
        constrain: true
        handle: '.todo-content'
        onComplete: (ele) ->
            sortableTodos.serialize false, (element,index) ->
                todo = Todos.get(element.getProperty("id")).replace("todo-","")
                todo.save("order":index)
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I often find I want to write code something like this in C#, but
I want to get the UCS-2 code points for a given UTF-8 string. For
The following code will generate a link to the page I want to get
I've decided I want to get more into native code development with C++. I'm
I want to capture the screen in my code to get an image -
I want to be able to get an estimate of how much code &
I want to be able to get an estimate of how much code &
I have code like this: class Base { public: void operator = (const Base&
I want to get started doing some game development using Microsoft's XNA. Part of
I want to get the MD5 Hash of a string value in SQL Server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.