0

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).

4
  • 1
    so why is the "old code" not working anymore? Commented Dec 3, 2012 at 19:59
  • 1
    Really can't get what you are trying to achieve. For me both variants do the job. Commented Dec 3, 2012 at 19:59
  • Or is it just that your ids have changed from #tb-sign-in-email to #tb-input-sign-in-email and this is why the "old code" selector isn't working anymore? Commented Dec 3, 2012 at 20:03
  • It is working both ways, that is not the question, I updated my question (last line). Sorry if the question was not clear enough the first time. Commented Dec 3, 2012 at 20:16

2 Answers 2

1

You can try using the .add() method

var textbox = this.forms.signIn ;

 (textbox.email).add(textbox.password).textbox();
Sign up to request clarification or add additional context in comments.

Comments

1

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();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.