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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:19:58+00:00 2026-05-24T22:19:58+00:00

There should be a glitch in my syntax, or something I haven’t understood, but

  • 0

There should be a glitch in my syntax, or something I haven’t understood, but when I am doing a save method on my model. The error callback is called whatever the outcome of the method.

    @new_activity = new Activity()

    @new_activity.save
        know: $('input#know').val()
        learn: $('input#learn').val()

        success: -> console.log 'success'
        error: -> console.log 'error'

In my case, since I do not really know whether the new_activity has effectively passed the validation, I have to do an ugly trick to add the activity to the collection. (By the way, I do not use the create method since I do want to have the different errors, and not a simple “false”.

    if @new_activity.has('know') and @new_activity.has('learn')
        app.collections.activities.add @new_activity

When it is successful though; there is an alert of the created model.

Edit: Further details.
Here is my model:
initialize: ->
_.bindAll @, ‘validate’, ‘errorHandler’
@.bind ‘error’, @errorHandler

validate: (attrs) ->
    errors = []
    # We only support a certain number of languages, we enforce that the user does not select a wrong set.
    if _.isEmpty(_.intersection([attrs.know], ['en', 'fr'])) is true
        errors.push 'This language is not currently supported.'

    if _.isEmpty(_.intersection([attrs.learn], ['en', 'fr', 'de', 'es', 'zh', 'pt', 'ar', 'ja', 'ru'])) is true
        errors.push 'You cannot learn this language yet.'

    if _.isEmpty(errors) is false
        errors

errorHandler: (model, error) ->
    console.log error

When the validation occurs, and if the validate method returns nothing, it still triggers the error event, and the error variable contains the model (but no error message).

  • 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-24T22:19:58+00:00Added an answer on May 24, 2026 at 10:19 pm

    You should check whether the new_activity is saved properly, please verify that the server returns success response to the PUT request.

    Furthermore, I have had issues with using Rails 3.1 standard format.json { head :ok } because it returns a single space as a reponse and application/json as content type. Backbone then tries to parse JSON and dies with an error.

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

Sidebar

Related Questions

There should be an error/omission in the next code but I can't see where
It seems like there should be something shorter than this: private string LoadFromFile(string path)
I'm pretty sure there should be a more Pythonic way of doing this -
It seems like there should be a removalAllOccuring(Collection) (or similiar) method in Multiset. A
I'm fairly sure there should be an elegant solution to this (in MATLAB), but
There should be a simple Linq query for what I'm trying to accomplish, but
I feel like there should be a simple way to do this but I
This problem smells like there should be an answer in graph theory, but it
I believe there should exist a known method for converting this: <div class=singlePane pane>
It seems like there should be a query for this, but I can't think

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.