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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:11:01+00:00 2026-06-07T05:11:01+00:00

I have an issue using an object property as jquery selector define([models/security/user, ‘text!templates/security/registration.html’], function(SecurityUserModel,

  • 0

I have an issue using an object property as jquery selector

define(["models/security/user", 'text!templates/security/registration.html'], function(SecurityUserModel, Template){

    var SecurityRegistrationView;

    SecurityRegistrationView = Backbone.View.extend({
        initialize: function(){
            // setting model
            this.model = new SecurityUserModel();

            // binding validation
            Backbone.Validation.bind(this);
            this.model.bind("validated:valid", this.valid);
            this.model.bind("validated:invalid", this.invalid);

            this.render();
        },
        form: {
            "username": "#_user_username"
            , "email": "#_user_email"
            , "password": "#_user_password"
        },
        render: function(){
            $(this.el).append(Template);
        },
        events: {
            "submit form": "submit"
        },
        submit: function(e){
            e.preventDefault();

            this.model.set("username", $(this.form.username).val());
            this.model.set("password", $(this.form.email).val());
            this.model.set("email", $(this.form.password).val());
            this.model.validate();

            if (this.model.isValid) {
                this.model.save();
            }
        },
        valid: function(model, attrs){
            console.log(attrs[0]);
            $(this.form[attrs[0]]).parent("div.control-group").addClass("success");
        },
        invalid: function(model, attrs){
            console.log(attrs[0]);
            $(this.form[attrs[0]]).parent("div.control-group").addClass("error");
        }
    });

    return SecurityRegistrationView;
});

Console output in chromium:

username registration.js:45
Uncaught TypeError: Cannot read property 'username' of undefined registration.js:46
password registration.js:45
Uncaught TypeError: Cannot read property 'password' of undefined registration.js:46
email registration.js:45
Uncaught TypeError: Cannot read property 'email' of undefined registration.js:46
username registration.js:45
Uncaught TypeError: Cannot read property 'username' of undefined registration.js:46



$(this.form.username).val(); // works
$(this.form[someVar]); // does not work
  • 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-07T05:11:03+00:00Added an answer on June 7, 2026 at 5:11 am

    this in your valid and invalid callbacks probably doesn’t refer to your view. Modify the bindings in your initialize method to the proper scope:

    this.model.bind("validated:valid", this.valid, this);
    this.model.bind("validated:invalid", this.invalid, this);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using XPreformatted to print some preformated text and I have an issue with
I have an issue using jquerys selectors when it comes to a page I
I have an issue using xsd dataTime with regard to integrating a web client
I have an issue with using the following code in my CakePHP app. In
I have an odd issue while using FlashCS4. I have a textfield that, when
First of all: I'm at Scala 2.8 I have a slight issue while using
i have an issue with synchronizing Master/slaves processes using MPI. I wish that the
I have this issue: first, I execute a SQL query using Java and then
We have an issue upgrading to SQL Server 2012. I am using the following
I have an issue going on here. I am using PHP to get values

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.