Using data variable to affect dialog
<p>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.</p>

<p>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 fuction such as data('type','row') and data('type','not_row'), but it seems like a waste.</p>

<p>Any suggestions?  Thank you</p>

<p><a href="http://jsfiddle.net/FYWY7/" rel="nofollow">http://jsfiddle.net/FYWY7/</a></p>

<pre><code>&lt;!DOCTYPE HTML&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
&lt;title&gt;Dialogs&lt;/title&gt;
&lt;link type="text/css" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/smoothness/jquery-ui.css" rel="stylesheet" /&gt;
&lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" language="javascript"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js" language="javascript"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
$(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');}
            }
        }
        ]
    });

});
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;input type="button" value="row" id="row" data-bla="whatever" /&gt;
&lt;input type="button" value="not_row" id="not_row" data-bla="whatever" /&gt;
&lt;div id="dialog"&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
