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

  • SEARCH
  • Home
  • 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 8661931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:36:58+00:00 2026-06-12T16:36:58+00:00

I have the following code: var $form = ”, $modal = ”, $submits =

  • 0

I have the following code:

 var $form = '',
    $modal = '',
    $submits = ''; 

 function createModal() {
        $modal = $.modal({
            title: title,
            closeButton: true,
            content: content,
            resizeOnLoad: true
        });
        $form = $modal.find('.form');
        $message = $modal.find('.message');
        $submits = $modal.find('.submit-button');
        href = $form.attr('data-href');
    }

Is there some way that I could add $form, $message and $submits to the $modal object as they are all related.

  • 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-12T16:36:59+00:00Added an answer on June 12, 2026 at 4:36 pm

    To associate data to a jQuery object, you may use the data function :

    The jQuery.data() method allows us to attach data of any type to DOM
    elements in a way that is safe from circular references and therefore
    free from memory leaks. jQuery ensures that the data is removed when
    DOM elements are removed via jQuery methods, and when the user leaves
    the page. We can set several distinct values for a single element and
    retrieve them later:

    • jQuery.data(document.body, ‘foo’, 52);
    • jQuery.data(document.body, ‘bar’, ‘test’);

    You usually need this because simply associate some properties to a jQuery object wouldn’t allow you to get the data back from another object wrapping the same element.

    In your case, if you keep a reference to your object, you may simply do

     function createModal() {
        var $modal = $.modal({
            title: title,
            closeButton: true,
            content: content,
            resizeOnLoad: true
        });
        return {
            $modal   : $modal,
            $form    : $modal.find('.form'),
            $message : $modal.find('.message'),
            $submits : $modal.find('.submit-button'),
            href     : $form.attr('data-href')
        };
    }
    
    var modal = createModal();
    

    So you keep only one clean reference to the whole thing and you may access modal.$modal or modal.$form.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: var modal = $.modal({ title: title, closeButton: true, content:
I have the following code: $.modal({ title: title, closeButton: true, content: content, complete: function
I have the following code: function submitHandler($link, $modal, close) { var $form = $modal.find('#main-form');
I have the following code: var submitHandler = function ($link, $form, close) { var
I have the following code: var formSubmitHandler = function (link, form) { //e.preventDefault(); var
I have the following code: var stereo_form =new Ext.form.FormPanel({ id: stereoInfo_panel, autoDestroy:true, frame: true,
I have the following Javascript code: function checkIfValid(){ var form = document.createuserform; var valid
I have the following Javascript code: function checkIfValid(){ var form = document.createuserform; if(form.fName.value ==
I have the following js code: function getSelectedPlace(form) { var places = 1 $(form).find(:input).each(function
I have the following code: var refreshId = setInterval(function() { $(#footad).html('myjshere'); }, 15500); Where

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.