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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:17:13+00:00 2026-05-13T17:17:13+00:00

I fear I may be losing my marbles today, because I don’t know how

  • 0

I fear I may be losing my marbles today, because I don’t know how to do what I want to. I want a custom prompt that I can call from any of my other JavaScript functions. I don’t know how to get this work, even though it feels like I’ve done it a hundred times.

Here is an example

var modal = function() {

    var prompt = function(msg) {
        // custom prompt builder here... let's return hard coded for example's sake
        return true;
    };

}();

var items = function() {
    var init = function() {

        $('.delete').click(function() {
            var confirm = modal.prompt('Are you sure you wanna delete that pal?');
        });

    };    


    $(document).ready(init);    
}();

What I want to be able to do is call the prompt method of modal, and get a return value based on the user input. Now this, I can do, but I am having problems calling the inner method. I want to group these together because I will probably have a custom modal alert() too.

Please don’t suggest the built in JavaScript OK/Cancel as I gotta do this custom.

Many thanks!

  • 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-05-13T17:17:14+00:00Added an answer on May 13, 2026 at 5:17 pm

    From the way you call modal.prompt, it appears you want the anonymous function to return an object that will be stored in modal:

    var modal = (function() {
        // various private fields & methods here
        ...
        // the public interface
        var self = {
            prompt: function(msg) {
                // custom prompt builder here... let's return hard coded for example's sake
                return true;
            }
        };
        return self;
    })();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to develop a GAE application using python, but I fear that Google
I fear I may be trying to do something that certain security policies are
I have read several questions regarding this but I fear they may be out
I fear this just may not be possible, but I'm trying to create a
I fear I may be displaying my ignorance with this question, but here goes...
Possible Duplicate: how to rename a project without killing solution I know that this
I have an idea I have yet to implement, because I have some fear
I fear this may be a dumb question/easy fix, but have been stuck for
We have several classes where a call to a member function may change state
I have been searching for and have not located (I fear it doesn't exist)

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.