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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:46:07+00:00 2026-06-14T21:46:07+00:00

I am trying to create a simple jQuery Plugin for myself to use (and

  • 0

I am trying to create a simple jQuery Plugin for myself to use (and yes I know there is already an official plugin with jQuery to do this sort of thing, but i prefer my own). I have got it basically coded up, the only issue that I don’t know how I could do is detect which button is clicked, and based on that call the corresponding function that is provided through the plugin. What would the best way be to do this?

So here’s my code so far:

(function($){
$.fn.extend({

    confirmDialog: function(options) {

        var defaults = {
           titleText: "Confirmation",
           bodyText: "Are you sure you want to delete this?",
           confirmButtonText: "Delete",
           confirmAction: function(){},
           cancelAction: function(){},
        };

        var options = $.extend(defaults, options);

        return this.each(function() {

    $('<div class="confirmation-box-wrapper"><div class="confirmation-box"><div class="confirmation-title">'+options.titleText+'</div><div class="confirmation-message">'+options.bodyText+'</div><div class="options"><a class="buttons cancel">Cancel</a><a class="buttons confirmation">'+options.confirmButtonText+'</a></div></div></div>').appendTo('body');  



        });
    }
});
})(jQuery);

So what I would expect the usage to be like is this:

 $(".elementToDelete").confirmDialog({
      confirmAction: function(){ alert("Deleted"); },
      cancelAction: function(){ alert("Cancelled"); }

  })
  • 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-14T21:46:09+00:00Added an answer on June 14, 2026 at 9:46 pm

    You need to bind the buttons in that extension. http://jsfiddle.net/4mjBb/

    var wrapper=$('<div class="confirmation-box-wrapper"... ...')appendTo('body'); 
    
    wrapper.find('.confirmation').on('click', function(){
        if (typeof options.confirmAction=='function') options.confirmAction();
    
    });
    wrapper.find('.cancel').on('click', function(){
        if (typeof options.cancelAction=='function') options.cancelAction();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first stab at trying to create a JQuery plugin, so I
I am trying to create very simple image browser with jQuery. I am doing
I am trying to create a simple about page that uses JQuery click to
I'm trying to create a simple AJAX uploader (as i know you can't actually
I'm trying out jstree, the jquery plugin to create a treeview. It works fine,
I'm trying to use jQuery SVG plugin http://keith-wood.name/svg.html And in the very beginning I
I'm trying to extend the jQuery autocomplete plugin with something as simple as: Superbox
I'm trying to create a simple RSS reader with Phonegap and jQuery. I am
Sorry this is my first time trying to create a plugin, so I might
I'm trying to create a jQuery effect for this block . The idea is,

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.