views:

83

answers:

1

Look this code guys:

<script type="text/javascript">

$("#<?=$delete_uid?>").click(function() {
    var id = $("#<?=$grid_uid?>").jqGrid('getGridParam','selrow');
    alert(id);
    if(id == null) {
        $.jGrowl("No selected Item");
        return;
    }

    confirm('Caution','Delete current selected item?', function(result) {
        if(result==true) {
            alert(id);
            url = "<?=ADMIN_URL?>/account/delete/id/" + id;
            execURL(url, function(result) {
                if (result==true) {
                    $.jGrowl("Item removed!!");
                    $("#<?=$grid_uid?>").trigger("reloadGrid");
                } else
                    $.jGrowl("Remove failure!!");
            });
        }
    });
});
</script>

obs: alert is for debugging purpose only.

In first pass id comes from jqgrid its write an everything its ok but, on second time id only in confirm function callback maintains the first value.

Please help, lost 3 hours on this!

+1  A: 

Try to use different syntax for 'confirm' function. Do not pass function to it, but use its return value as result:

 if(confirm('Caution','Delete current selected item?')){
            alert(id);
            url = "<?=ADMIN_URL?>/account/delete/id/" + id;
            execURL(url, function(result) {
                if (result==true) {
                    $.jGrowl("Item removed!!");
                    $("#<?=$grid_uid?>").trigger("reloadGrid");
                } else
                    $.jGrowl("Remove failure!!");
            });
 };

This should help.

nemisj
solved thanks man!!
CrazyJoe