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 8789337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:22:44+00:00 2026-06-13T22:22:44+00:00

I just watched the backbone.js railscasts and Im not getting the error alert when

  • 0

I just watched the backbone.js railscasts and Im not getting the error alert when the name is not present but do get an error on the server side.

im using rails 3.2.8 and backbone-on-rails 0.9.2.3

In the network console it does state that theres an error with the api/entries, and in the response theres the errors key, but still no alert when I click add with nothing on the form.

This is my code… please help me figure out what could be wrong!

class Raffler.Views.EntriesIndex extends Backbone.View

  template: JST['entries/index']

  events:
    'submit #new_entry': 'createEntry'
    'click #draw': 'drawWinner'

  initialize: ->
    @collection.on('reset', @render)
    @collection.on('add', @appendEntry)

  render: =>
    $(@el).html(@template())
    @collection.each(@appendEntry)
    this

  appendEntry: (entry) =>
    view = new Raffler.Views.Entry(model: entry)
    @$('#entries').append(view.render().el)

  drawWinner: (event) ->
    event.preventDefault()
    @collection.drawWinner()

  createEntry: (event) ->
    event.preventDefault()
    attributes = name: $('#new_entry_name').val()
    @collection.create attributes,
      wait: true
      success: -> $('#new_entry')[0].reset()
      error: @handleError

    handleError: (entry, response) ->
      if response.status == 422
        errors = $.parseJSON(response.responseText).errors
        for attribute, messages of errors
          alert "#{attribute} #{message}" for message in messages

Thank you!

  • 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-13T22:22:46+00:00Added an answer on June 13, 2026 at 10:22 pm

    Your indentation is wrong so you don’t have a @handleError, instead your createEntry method is returning an object like this:

    { handleError: (entry, response) -> ... }
    

    So when you try to use @handleError as an error callback:

    @collection.create attributes,
      wait: true
      success: -> ...
      error: @handleError # <----------- Here
    

    you’re really saying:

    @collection.create attributes,
      wait: true
      success: -> ...
      error: undefined
    

    and setting your error callback to undefined doesn’t do anything useful.

    Pull handleError back towards the left margin two spaces and you might have better luck.

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

Sidebar

Related Questions

Just checking my JS and I have an error, but I cannot see where.
so I've watched http://railscasts.com/episodes/43-ajax-with-rjs but I have a question: In my view I have
Possible Duplicate: When do you prefer using std::list<T> instead of std::vector<T>? I just watched
I just watched a recording of a conference presentation. The presenter was using VS
I trying to learn BDD way for development and just watched RailsCasts lesson for
I just watched the railscasts for multistep forms , and I now have a
I've read the questions on S.O. regarding Singleton and just watched an hour long
I just watched a video of Douglas Crockford's presentation about his 2009 book JavaScript:
Having watched samples from Rob Conery's Kona application, I see that he is using
In school, one of my professors had created a 3D game (not just an

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.