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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:31:44+00:00 2026-06-04T20:31:44+00:00

I have these two set of codes, one is to prompt whenever the button

  • 0

I have these two set of codes, one is to prompt whenever the button is clicked,

$('.button_class').click(function(){
    var baker_url = base_url + 'baker/baker/manage/Bread/1';
    var answer = confirm('Are you sure?');
    if(answer == true){
        // if this is true, i will call an external script so that within this condition that process will be executed
    }
    else if(answer == false){
        return false; // exits
}
});

and then this piece of code right here is the one responsible for executing the process when the button is clicked,

$('.another_button_class').click(function(e){
        e.preventDefault();
        var baker_url = base_url + 'baker/baker/manage/Bread/1';
        var form    = '#'+ $(this).attr('rel');
        var url     = $(form).attr('action');
        var target  = '#'+ $(form).attr('rel');
            $(target).slideUp();
            $.post(url, $(form).serialize(),function(data) {
                $(target).html(data).slideDown(function(){
                    if(data == '<div class="ok">Added</div>'){
                    setTimeout(refresh,1000)
                    c();
                    window.location = baker_url; // sets the url after refreshing
                    }
                });

            });
    });

in the first function, when answer == true, i want to execute the latter function (the one with the process execution when button is clicked).

Is it really possible that I can call an another function or event handler to execute its process inside another function?

  • 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-04T20:31:45+00:00Added an answer on June 4, 2026 at 8:31 pm

    If I understand the question correctly, you have an effect that needs to happen either when you click button #2 or when you click button #1 AND click yes in a prompt?
    If so I can think of three options:

    1. Name the second function and make it work if e is undefined; all it really does with it is prevent default. You could then call the named function from the first event.

    2. Better version of 1: Make a new function that does everything except e.preventDefault(); in the second piece of code. You could then call this from both events.

    3. Use jQuery to simulate a click event for the second button, if ‘yes’ is selected at the first one.

    EDIT The second one would be preferable in this case. Use the third one if you actually need the event object for something.

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

Sidebar

Related Questions

I have these two methods on a class that differ only in one method
I have a set of unique elements (there are not two identical elements). And
I have these two lines in my web.xml <url-pattern>/</url-pattern> : Index Servlet and <url-pattern>/login</url-pattern>
I have these two tables people ============ id, name and answer_sheets ============ id, person_id,
I have these two modules : package G1; sub new { my $class =
I have these two classes public class Person { } public class Company {
I have these two situations: String s = aa; s = s + aa;
I have these two functions (with Point2D & LineVector (has 2 Point2D member variables)
I have these two images. And... I made them into graysclae images and then
I have these two URL's I want to make available to my users: /Account/Orders

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.