Jquery函数获取id的旧值(带模态确认)

时间:2016-01-03 05:18:14

标签: jquery modal-dialog confirm

我有问题。我的onclick链接就是这个。

<a onClick='ConfveAjaxFormPost(this)' id='$idid' adi='$nei'look='nlme' 
   mdl-tit='title here' 
   mdl-p1='text1here' 
   mdl-p2='text2 here' 
   mdl-btn='del' 
   data-toggle='modal' data-target='#modalonay'>DEL</a>

这是ConfveAjaxFormPost(this)功能......

function ConfveAjaxFormPost(alink) {


var ConfveAjaxFormPost_look =  alink.getAttribute('look');      
var ConfveAjaxFormPost_id =  alink.getAttribute('id');  
var ConfveAjaxFormPost_adi = alink.getAttribute('adi');


/*modal win texts*/
var ConfveAjaxFormPost_tit =  alink.getAttribute('mdl-tit');    
var ConfveAjaxFormPost_p1 = alink.getAttribute('mdl-p1');
var ConfveAjaxFormPost_p2 = alink.getAttribute('mdl-p2');
var ConfveAjaxFormPost_btn = alink.getAttribute('mdl-btn');

$('.modal-title').html(ConfveAjaxFormPost_tit);
$('.sorukismi').html(ConfveAjaxFormPost_p1);
$('.sorukismi2').html(ConfveAjaxFormPost_p2);
$('.modal_confirm_butt').html(ConfveAjaxFormPost_btn);


    $(".modal_confirm_butt").click(function () {



    $this = $(this);
    if ($this.data().isSubmitted) {return false;}/** duplicate false */


        $.ajax({
                    url:'start.php',
                    type:'POST',
                    data: { OnayveAjaxFormPost_look: OnayveAjaxFormPost_look, OnayveAjaxFormPost_id: OnayveAjaxFormPost_id, OnayveAjaxFormPost_adi: OnayveAjaxFormPost_adi},

                    success:function(data){
                        if     (data == 1){}
                        else if(data == 2){}                        
                        else              {}
                    }


              });

    $this.data().isSubmitted = true; 
    return true;              



    });
}

我在一个页面上有一些操作链接。当我点击链接显示模态确认时,然后单击NOT CONFIRM按钮,稍后我点击另一个操作链接并确认它,函数$.ajax发布之前的值(发送旧ID和值)

请帮助..谢谢

1 个答案:

答案 0 :(得分:0)

在每个点击事件更改变量中:

var ConfveAjaxFormPost_look =  alink.getAttribute('look');      
var ConfveAjaxFormPost_id =  alink.getAttribute('id');  
var ConfveAjaxFormPost_adi = alink.getAttribute('adi');

To(没有“var”)

ConfveAjaxFormPost_look =  alink.getAttribute('look');      
ConfveAjaxFormPost_id =  alink.getAttribute('id');  
ConfveAjaxFormPost_adi = alink.getAttribute('adi');
  

我从中学到了这些,[https://stackoverflow.com/users/1343450/rakesh-sadhula]谢谢你,拉克什......