Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Validation too late #8

@Chali-Anne

Description

@Chali-Anne

I have the same issue as https://github.com/powmedia/backbone-deep-model/issues/86.

Using Backbone.Validation and Backbone.Stickit, I am trying to validate nested attributes and show error messages dynamically.

Short example of the setup I am using :

var myModel = Backbone.DeepModel.extend({
   validation:{
       'user.phoneNumber':{
             min : 1
        }
   };
});

var view = Marionette.ItemView.extend({
    bindings:{
          "#phoneNumberInput" : {
              observe : "user.phoneNumber",
              setOptions:{
                   validate:true;
               }
           }
    },
    initialize:function(){
        Backbone.Validation.bind(this,
             forceUpdate:true,
             valid:function(){
                  // code to hide error message
             } ,
             invalid:function(){
                  // code to show errror
             }
      );
    },
    onRender:function(){
          this.stickit();
    }
});

The model is assigned to the view when it is created.

I get the error displayed only after the second invalid input. Validation works when the input loses focus.

Can someone tell me what I am doing wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions