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

  • SEARCH
  • Home
  • 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 9224781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:24:40+00:00 2026-06-18T04:24:40+00:00

I have my javascript in backbone.js with coffeescript instead javascript: TodoItem = Backbone.Model.extend( toggleStatus

  • 0

I have my javascript in backbone.js with coffeescript instead javascript:

TodoItem = Backbone.Model.extend(
  toggleStatus ->
    if @.get 'status' is "incomplete"
      @.set 'status': 'complete' 
    else
      @.set 'status': 'incomplete'
    @.save()  
)

todoItem = new TodoItem(
  description: 'Play the guitar'
  status: 'incomplete'
  id: 1
)

TodoView = Backbone.View.extend(
  tagName: 'div'
  id: "box"
  className: 'red-box'

  template: 
    _.template "<h3> <input type=checkbox #{ print "checked" if status is "complete"} /> <%= description %></h3>"

  events: 
    "click h3": "alertStatus"
    'change input': 'toggleStatus'

  toggleStatus: ->
    @.model.toggleStatus()

  alertStatus: ->
    alert('Hey you clicked the h3!')

  render: ->
    @.$el.html @.template(@.model.toJSON())
)

todoView = new TodoView({model: todoItem})
todoView.render()
console.log todoView.el

Backbone version is the last version 0.9.10 and underscore.js version is last version 1.4.4

The coffeescript file compile fine however I get in console:

Uncaught ReferenceError: toggleStatus is not defined main.js:5

(anonymous function) main.js:5

(anonymous function)

Thanks!

  • 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-06-18T04:24:41+00:00Added an answer on June 18, 2026 at 4:24 am

    I guess that you’re trying to assign a anonymous function to your object at key toggleStatus at line 2.

    Then, you just forget the : when declaring toggleStatus.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get a CoffeeScript class to extend a Backbone.Model. I built
I have a model : window.LayerModel = Backbone.Model.extend({ defaults:{ 'id':'unknow', 'type':'unkonw', 'preId':'unknow', 'data': {}
I'm using javascript with backbone and adobe air. In my view model, I have
I have the following model: var Soq = Backbone.model.extend({ default:{ 'name': 'something' , 'parents':
I have created a new backbone.js widget model which I hope to extend: var
I have JavaScript application, where I use client-side templates (underscore.js, Backbone.js). Data for initial
So basically I have my backbone application making an ajax GET call to my
I am trying to model friendships using the Parse.com javascript API (essentially backbone models).
I have a backbone app with over 50 small JavaScript files. Now I want
I have several backbone.js views, javascript modules and style sheets in an ASP.Net MVC

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.