0

我一直在尝试为我的网站使用引导模式。现在我需要更改以下代码以与模态一起使用

$(document.body).on('click','.socialIcon',null,function() {
    var id = $(this).attr('id').replace('social_','');
    var win = function(resp) {
        var dialogWin = $('#socRegPopup');
        if(dialogWin.length){
            dialogWin.remove();
        }
        $('#wrapper').append(resp);  
        dialogWin = $('#socRegPopup');
        dialogWin.dialog({ 
            autoOpen: true,
            width: 515,
            modal: true,
            position: 'center',
            resizable: false
        });
    };
    $.ajax({
        url: liveSite +'/index2.php?obj=social&task=getSocialForm',
        type:'get',
        data: {programId: id},
        success:win});    
});

我尝试将其更改为此以使用引导模式

$(document.body).on('click','.socialIcon',null,function() {
    var id = $(this).attr('id').replace('social_','');
    var win = function(resp) { 
        $('#wrapper').append(resp);  
        $('#socRegPopup').modal();
    };
    $.ajax({
        url: liveSite +'/index2.php?obj=social&task=getSocialForm',
        type:'get',
        data: {programId: id},
        success:win});    
});

这个可行,但问题是数据没有改变,例如当我单击按钮 1 时有 3 个按钮,它将输出正确,但接下来的所有按钮将输出按钮 1 数据。任何指南如何使模态在 ajax 上工作

4

1 回答 1

0

这解决了我的问题。我不知道这是否是一个更好的解决方案

$(document.body).on('click','.socialIcon',null,function() {
    var id = $(this).attr('id').replace('social_','');
    var win = function(resp) { 

        var element = document.getElementById("socRegPopup");
        if(element){
        element.parentNode.removeChild(element);
     } 

        $('#wrapper').append(resp);  
        $('#socRegPopup').modal();
    };
    $.ajax({
        url: liveSite +'/index2.php?obj=social&task=getSocialForm',
        type:'get',
        data: {programId: id},
        success:win});    
});
于 2013-07-14T15:32:26.593 回答