I have a backbone view that handles a registration component, because it requires a lot of farm access, the object property Select the selectors in Define (<"model / security / user", 'text! Template / security / registration html'], function (security purpose model, template) {var protectedist's status view; security registration view = backbone. View extension ({start: function} (this.model = new securityUserModel (); this.model.bind ("valid: valid", this is valid); this.model.bind ("valid: invalid", this .invalid); validity; stop (this); this.render ();}, render: function () {$ (this.el) .append (template);}, Evey Submit "Submit" ("#_user_email"), "password": $ ("#_user_password")} submit, submit: "submit"}, form: {"username": $ ("# _ User_username ")," email ": function (e) {e.preventDefault (); this.model.set (" user name ", this.form.username.val ()); this.model.set (" Password ", this.form.email.val ()); This.mode L.set (" email ", this.form.password.val ()); this.model.validate (); // debug console.log ([This.form, this.form.username.val (), this.form.email.val ()]; if (this.model.isValid) {this.model.save (); }}, Valid: function (model, etter) {// error this.form.attrs [0]. ("DivControl-group"). AddClass ("success"); }, Invalid: function (model, etter) {// error this.form.attrs [0]. User name. ("DivControl-group"). AddClass ("Error"); }}); Return security transcript view; });
When I do this. Console.log, I have an object that looks anything good enough to be undefined or weird:
[item email: e.fn.e.init [0] reference: HTMLDocument Selector: " #_user_email "__proto__: object [0] password: e.fn.e.init [0] Reference: HTMLDocument Selector:" #_user_password "__proto__: Object [0] User Name: E.fn.e.init [0] Reference : HTMLDocument Selector: "#_user_username" __proto__: object [0] __proto__: object] To access selectors, log in to a jquery function (this is .form.username.val ( )) With undefined Fruit remains.
Why jQuery's functions on properties can not be used ($ el uses this) Where's the thinking error?
I think the problem is, form: {...} The evaluation is done before and the HTML element that you query is created in render . You may try at the end of the render function : this.for (" #_user_mail ")," password ": $ (" #_user_password ")}
Comments
Post a Comment