Reputation: 2970
Take a look at the following code:
this.forms = {
signIn: {
email: $('#tb-input-sign-in-email'),
password: $('#tb-input-sign-in-password')
},
signUp: {
fullName: $('#tb-input-sign-up-full-name'),
email: $('#tb-input-sign-up-email'),
password: $('#tb-input-sign-up-password')
}
};
This is my old code that initializes my textbox jQuery plugin:
$('#tb-sign-in-email, #tb-sign-in-password').textbox();
The new code (using the this.forms array) would be:
this.forms.signIn.email.textbox();
this.forms.signIn.password.textbox();
Basically I want to initialize the textbox plugin with one line of code just as the "old code" initializes the jQuery plugin (with a single selector).
Upvotes: 0
Views: 236
Reputation: 55750
You can try using the .add()
method
var textbox = this.forms.signIn ;
(textbox.email).add(textbox.password).textbox();
Upvotes: 1
Reputation: 26320
Your current code only get the elements on DOM using a jQuery selector, the same happens on the old code.
The difference is that the new code changes the selectors.
From #tb-sign-in-email
to #tb-input-sign-in-email
.
From #tb-sign-in-password
to #tb-input-sign-in-password
.
$('#tb-input-sign-in-email, #tb-input-sign-in-password').textbox();
Upvotes: 1