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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:52:47+00:00 2026-06-11T07:52:47+00:00

var contactForm = { form: $(‘.contact’), button: $(‘button’), config: { type: ‘slideDown’, }, init:

  • 0
var contactForm =
    {
        form: $('.contact'),
        button: $('button'),
        config: {
            type: 'slideDown',
        },

        init: function (config)
        {
            $.extend(this.config, config);

            contactForm.button.on('click', function() 
            {
                if(contactForm.form.is(':hidden'))
                    this.showForm();
                else
                    this.closeForm();
            });
        },

        showForm: function ()
        {
            contactForm.form[contactForm.config.type](2000);
        },

        closeForm: function ()
        {
            contactForm.form.slideUp(2000);
        },
    };

    contactForm.init();

In init() function, I tried to call showForm() and closeForm() methods by using ‘this’. However, ‘this’ is appointed to the click element. (the button)

How can I prevent this?

I always want ‘this’ to contain struct/class object. If I want a button object be appointed, I want it to be appointed into $(this), not this.

  • 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-11T07:52:49+00:00Added an answer on June 11, 2026 at 7:52 am

    Use:

    init: function (config)
    {
        var self = this;
        $.extend(this.config, config);
    
        self.button.on('click', function() 
        {
            if(contactForm.form.is(':hidden'))
                self.showForm();
            else
                self.closeForm();
        });
    },
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a pretty straight-forward javascript form validation script written: function validateForm(){ var x=document.forms[contactForm][firstname].value;
var JavascriptHelper = Backbone.Model.extend(JavascriptHelper, {}, // never initialized as an instance { myFn: function()
var messageSpan; function createFlashMessage = function(message, type, time) { messageSpan || (messageSpan = $(<span>).hide().appendTo(body));
I'm using jQuery's AJAX function to send a message from a contact form -
I'm building a contact form and I need help with the jQuery validator. function
I am using the following script for validate my contact form. //submission scripts $('.contactForm').submit(
I have a div with the id hubspot-contact-form. This div has a display style
I have the following JQuery to submit a contact form with jquery ajax. This
I'm trying to add a file upload function to a contact form, but it
Arrg. I can't spot the endless loop in this contact form. The thanks div

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.