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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:21:41+00:00 2026-06-07T16:21:41+00:00

I have created a modal plugin that has options defined by default or the

  • 0

I have created a modal plugin that has options defined by default or the user.
The majority of these values will be passed to a function and updated, when this happens, I want the value to be updated in the options. Ideally I don’t want to have to update each individual one, and want to handle and update the object (options) as a whole.

the following is the users options:

modalDialog({
    ID: 'before_unload',
    title: 'opt.heading',
    message: 'opt.text',
    confirm: 'opt.confirm',
    cancel: 'opt.cancel',
    link: $(this).attr('href'),
});

Each of the options beginning with ‘opt.’ will have the function performed on them.
Here is the code for the modalDialog plugin that deals with the options

var options = $.extend(defaults, options);
        return this.each(function() {
            var o = options;
            var reg = '^opt.*'; //regex to find all 'opt.' values
            console.log(o);
            $.each(o, function(i, v) { //for each value
                if(i != 'save'){    
                    if(v.match(reg)){ // match to regex
                        console.log(i+': '+v);
                        var newval = rc.getResource(v); // function to update value
                        console.log(newval); //value has been updated, function works
                        v = i.replace(i, newval); // update the index with new value
                        console.log('New i:v = '+i+': '+v); // checked and it works

//Now the question is, how do I update o (options with the new values?)

                    }
                };
            });

In the code above, lets pretend that rc.getResource(v) come back with a different farm animal name depending on which value gets passed to it, I update the value with my new farm animal name, and check that it all matches up and everything is working up until I get to updating the options. I have tried o = options.replace(i,v) and it come back with options.replace is not a function.

One thought I did have was after I have created a new value (performed my function) unset/delete the corresponding i:v and add the new value to the object, e.g.

i1 = i;
v1 = i.replace(i, newval);
o -=  i:v;
o += i1:iv;

Alas, my brain is frazzled and am in desperate need of help, which would be greatly appreciated!

  • 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-07T16:21:43+00:00Added an answer on June 7, 2026 at 4:21 pm

    Can’t you just do this?:

    o[i] = v;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a modal dialog that is created with the following: procedure TFormCompose.createParams(var Params:
I have created a dialog with the JQuery dialog plugin. My dialog is defined
I have a page that has two tabs created using jQuery, and I am
I have created a model test case in a plugin. Plugin name: Filters and
I have created a Company model and a profile model. Every User belongs to
if i have created a view model and have a partial form that is
I have a page that uses Ryan Bates nested_form plugin . The plugin is
I have an API that services a web-based plugin for processing email. The API
I have created a pdf version of our rails application using the Prawn plugin,
I'm trying to create a plugin for nopCommerce v2.20 that allows the user to

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.