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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:27:32+00:00 2026-06-03T22:27:32+00:00

I would like to have a dialog common to two different call-to-action buttons (row

  • 0

I would like to have a dialog common to two different call-to-action buttons (row and not_row). Each of the buttons would set a different data() variable. Based on which variable is set, the dialog would react differently.

The following almost works. Problem is that if row is first clicked, then not_row, $(this).data(‘row’) remains set so the if statement doesn’t act accordingly. One option is to add another data variable in my click function such as data(‘type’,’row’) and data(‘type’,’not_row’), but it seems like a waste.

Any suggestions?

http://jsfiddle.net/FYWY7/

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Dialogs</title>
<link type="text/css" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/smoothness/jquery-ui.css" rel="stylesheet" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" language="javascript"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js" language="javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
    $("#not_row").click(function(){$("#dialog").data('id',$(this)).dialog("open");});
    $("#row").click(function(){$("#dialog").data('row',$(this)).dialog("open");});

    $("#dialog").dialog({
        autoOpen    : false,
        resizable   : false,
        height      : 330,
        width       : 430, 
        modal       : true,
        buttons: [
        {
            text    : 'CLICK',
            click   : function() {
                $(this).dialog("close");
                if($(this).data('row')) {alert('row');}
                else {alert('not row');}
            }
        }
        ]
    });

});
</script>
</head>
<body>
<input type="button" value="row" id="row" data-bla="whatever" />
<input type="button" value="not_row" id="not_row" data-bla="whatever" />
<div id="dialog"></div>
</body>
</html>
  • 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-03T22:27:34+00:00Added an answer on June 3, 2026 at 10:27 pm

    This was my solution. The purpose of this script is to delete records. If on a main page, then pass the ID, delete the record, and reload the page. Or you might delete a row off a list, so pass the row which contains the ID as an attribute, delete the record, and remove the row from the DOM. My solution was to check whether the passed variable was an object or a number (string).

    PS. Thanks Ravi

    <!DOCTYPE HTML>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Dialogs</title>
    <link type="text/css" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/smoothness/jquery-ui.css" rel="stylesheet" />
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" language="javascript"></script>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js" language="javascript"></script>
    <script type="text/javascript">
    $(document).ready(function(){
        $("#not_row").click(function(){$("#dialog").data('id',$(this).attr('data-id')).dialog("open");});
        $("#row").click(function(){$("#dialog").data('row',$(this)).dialog("open");});
    
        $("#dialog").dialog({
            autoOpen    : false,
            resizable   : false,
            height      : 330,
            width       : 430, 
            modal       : true,
            buttons: [
            {
                text    : 'CLICK',
                click   : function() {
                    $(this).dialog("close");
                    if(typeof $(this).data('i') == "object") {alert('Delete record and delete row');}
                    else {alert('Delete record and redirect');} 
                }
            }
            ]
        });
    
    });
    </script>
    </head>
    <body>
    <input type="button" value="Delete Row" id="row" data-id='123' />
    <input type="button" value="Delete ID" id="not_row" data-id='234' />
    <div id="dialog"></div>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Delphi 7, I have a model dialog and i would like to display
i would like to have my rate button in my dialog to launch marketplace
I have some common Javascript which I would like to execute on the event
I've created my own (custom) Dialog. But would like to have its style like
Within my application I would like to have a dialog box or a form
I have jQuery dialog working with my custom theme. I would like to use
When loading data into my Fragments I would would like to have an indeterminate
How to create a confirm dialog box in dojo? I would like to have
I have a screen where I have some buttons. I would like to know
So in my project i would like have a nice treeview that has images.

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.