Jquery 确认问题

Jquery 确认问题,jquery,jquery-plugins,Jquery,Jquery Plugins,我目前正在使用Confirmation jQuery插件,该插件位于以下位置: 我现在的问题是,我有一个图标,它会调用“询问”对话框,询问它是否要确认删除该项,但是我还有一个按钮,单击该按钮后,将从用户要删除的项的复选框中创建一个值数组,然后确认删除这些项,但我在处理这些项时遇到了问题同一页上有多个用途。任何建议 编辑帖子: /* * jQuery Plugin : jConfirmAction * * by Hidayat Sagita * http://www.webstuffs

我目前正在使用Confirmation jQuery插件,该插件位于以下位置:

我现在的问题是,我有一个图标,它会调用“询问”对话框,询问它是否要确认删除该项,但是我还有一个按钮,单击该按钮后,将从用户要删除的项的复选框中创建一个值数组,然后确认删除这些项,但我在处理这些项时遇到了问题同一页上有多个用途。任何建议

编辑帖子:

/*
 * jQuery Plugin : jConfirmAction
 * 
 * by Hidayat Sagita
 * http://www.webstuffshare.com
 * Licensed Under GPL version 2 license.
 *
 */
(function($){

jQuery.fn.jConfirmAction = function (options) {

    // Some jConfirmAction options (limited to customize language) :
    // question : a text for your question.
    // yesAnswer : a text for Yes answer.
    // cancelAnswer : a text for Cancel/No answer.
    var theOptions = jQuery.extend ({
        question: "Are you sure?",
        yesAnswer: "Yes",
        noAnswer: "No"
    }, options);

    return this.each (function () {

        $(this).bind('click', function(e) {

            e.preventDefault();
            thisHref    = $(this).attr('href');

            if($(this).next('.question').length <= 0)
                $(this).after('<div class="question">'+theOptions.question+'<br/> <span class="yes">'+theOptions.yesAnswer+'</span><span class="no">'+theOptions.noAnswer+'</span></div>');

            $(this).next('.question').animate({opacity: 1}, 300);

            $('.yes').bind('click', function(){
                if($('#myhiddenPageToken').val() == "useraccounts"){ useraccounts(this); }
                else if($('#myhiddenPageToken').val() == "someotherpage"){ someotherfunction(); }
                else{/*do nothing*/}
            });

            $('.no').bind('click', function(){
                $(this).parents('.question').fadeOut(300, function() {
                    $(this).remove();
                });
            });

        });

    });
}

})(jQuery);

function useraccounts(whatsThis) { 
var userID =$(whatsThis).parents('td').find('img').attr('id');
var dataString = 'userID=' + userID + '&deleteuser=True'; 
$.ajax({ 
    type: "POST", 
    url: "processes/useraccounts.php", 
    data: dataString, 
});
$(whatsThis).parents("tr").eq(0).hide();    
}


<?php
session_start();
require("../inc/dbconfig.php");
require("../inc/global_functions.php");

// find out how many rows are in the table 
$query = "SELECT CONCAT_WS(' ',firstName,lastName) AS name, username, emailAddress, userID FROM manager_users WHERE statusID != 4";
$result = mysqli_query($dbc,$query);

$fileName = basename($_SERVER['PHP_SELF']);
$pageName = "User Accounts";
$userData = $_SESSION['user_data'];
$userID = $userData['userID'];
?>

<script type="text/javascript">
$(document).ready(function() {

$('#usersPageList').dataTable( {
    "sDom": 'rti<"pagination"p>',
    "iDisplayLength": 10,
    "sPaginationType": "full_numbers",
} );

var info = $('.dataTables_info')
var clone = info.clone();
info.hide();
$('tfoot tr td.rounded-foot-left').append(clone);



$('a.bt_green').click(function(e) {
    e.preventDefault();
    $('div.right_content').load('forms/addnew/' + $(this).attr('id'));
});

$('table tr').click(function() {

    checkBox = $(this).children('td').children('input[type=checkbox]');

    if(checkBox.attr('checked'))
        checkBox.removeAttr('checked');
    else
        checkBox.attr('checked', 'checked');

});

$('.ask').jConfirmAction();

$('.ask2').jConfirmAction();    

});
</script>

<h2>User Accounts</h2> 

<table id="usersPageList" class="rounded-corner">

<thead>

    <tr>

        <th scope="col" class="rounded-first"></th>
        <th scope="col" class="rounded">Name</th>
        <th scope="col" class="rounded">Email Address</th>
        <th scope="col" class="rounded">Username</th>
        <th scope="col" class="rounded">Edit</th>
        <th scope="col" class="rounded-last">Delete</th>

    </tr>

</thead>

<tfoot>

    <tr>

        <td colspan="5" class="rounded-foot-left"></td>
        <td class="rounded-foot-right">&nbsp;</td>

    </tr>

</tfoot>

<tbody>

    <?php 
    while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
        echo "<tr>";
            echo "<td><input type=\"checkbox\" name=\"users[]\" value=\"".$row['userID']."\"/></td>";
            echo "<td>".$row['name']."</td>";
            echo "<td>".$row['emailAddress']."</td>";
            echo "<td>".$row['username']."</td>";
            echo "<td><a href=\"#\"><img src=\"images/user_edit.png\" alt=\"\" title=\"\" border=\"0\" id=\"".$row['userID']."\" /></a></td>";
            echo "<td>";
            if (($row['userID'] !== '10000') && ($row['userID'] !== $userID)){
                echo "<a href=\"#\" class=\"ask\"><img src=\"images/trash.png\" class=\"delete\" alt=\"\" title=\"\" border=\"0\" id=\"".$row['userID']."\" /></a>";
            }
            echo "</td>";
        echo "</tr>";
    }
    ?> 

</tbody>

</table>

<?php
addRemove($fileName,$pageName);
?>

<input type="hidden" name="myhiddenPageToken" id="myhiddenPageToken" value="useraccounts" />
/*
*jQuery插件:jconfirmation
* 
*矢田秀代
* http://www.webstuffshare.com
*根据GPL版本2许可证许可。
*
*/
(函数($){
jQuery.fn.jconfiraction=函数(选项){
//某些JConfirmation选项(限于自定义语言):
//问题:你的问题的文本。
//yesAnswer:答案是肯定的文本。
//cancelAnswer:用于取消/无应答的文本。
var theOptions=jQuery.extend({
问题:“你确定吗?”,
yesAnswer:“是的”,
不回答:“不”
},选项);
返回此值。每个(函数(){
$(this).bind('click',函数(e){
e、 预防默认值();
thisref=$(this.attr('href');

if($(this).next('.question')).length我要做的是给按钮一个特定的类,然后复制“each”的内容。另外,你可以做两个“theOptions”,这样你就可以有不同的文本,将类重命名为“yes”和“no”很重要。我对你的代码不是很熟悉,所以如果你发布你的HTML,也许我可以帮助你更好

return this.hasClass('class1').each (function () {
    //the stuff you want to do here
}


return this.hasClass('class2').each (function () {
    //the stuff you want to do here
}

我把它贴在上面,谢谢你的回复。这只使用了提问中的一个。问题是我不确定如何实施第二个提问,因为如果用户在ask2上单击“是”,它将执行不同的任务。对此有任何其他建议吗?嗯,不,我稍后再看!