javascript - 对话框未打开 ajax jquery MVC2 asp.net

标签 javascript jquery asp.net ajax modal-dialog

删除对话框未打开 我的代码 查看:

 `<div id="dialog-confirm" title="Delete dialog" style="display: none;">
    <p>
        Are you sure you want to delete the point?
    </p>
    </div>`

JavaScript:

 `options += '<div onclick="editPoint(' + id + ')">Edit</div>
    <div onclick="deletePoint('   + id + ')">Delete</div>';
     optionsBox.html(options);`

Controller : 公共(public)字符串delete_marker(字符串Id) { 尝试 { mapmaker_dbDataContext DB = new mapmaker_dbDataContext(); DB.SP_DeletePoint ( Id,/"Innayat"/User.Identity.Name ); return "点删除成功"; } catch(异常除外) { return "删除操作失败"; } }

删除功能:

function deletePoint(id) {

    MapScript.removeOptionsBox();
    $( "#dialog-confirm" ).css('display','block');
    alert('in detele');
    $( "#dialog-confirm" ).dialog({

          resizable: false,
          height:140,
          modal: true,
          buttons: {
            "Delete": function() {                
                var link = '<%= Url.Action("delete_marker", "Home", new { id = "-1" }) %>';
                 link = link.replace("-1",id);
                    $.ajax({
                        url: link,
                        type: "GET",
                        cache: false,
                        success:
                                function (data) {
                                    //alert(data);
                                    if($('.up-triangle.firstAnimationA').length || $('.up-triangle.firstAnimationB').length )
                                        //LoadList(0);
                                        LoadNeighborhoodList(0, MapScript.neighborhoodCenter.latitude, MapScript.neighborhoodCenter.longitude);
                                    if($('.up-triangle.secondAnimationA').length || $('.up-triangle.secondAnimationB').length )
                                        //LoadList(1);
                                        LoadNeighborhoodList(1, MapScript.neighborhoodCenter.latitude, MapScript.neighborhoodCenter.longitude);
                                    if($('.up-triangle.thirdAnimationA').length || $('.up-triangle.thirdAnimationB').length )
                                        {
                                            //LoadList(2);
                                            LoadNeighborhoodList(2, MapScript.neighborhoodCenter.latitude, MapScript.neighborhoodCenter.longitude);
                                        }
                                },
                        error: function(){
                            alert('Delete operation failed');
                        }
                    });
              $( this ).dialog( "close" );
              $( "#dialog-confirm" ).css('display','none');
                alert('delete button clicked');

            },
            "Cancel": function() {
              $( this ).dialog( "close" );
              $( "#dialog-confirm" ).css('display','none');
            }
          }
        });
    $( "#dialog-confirm" ).dialog();


}

它给出的错误代码有什么问题?即使我用警报替换 ajax 功能,它也会再次给出错误

最佳答案

在加载正文或文档上声明您的对话框 div,如下所示...

$(function() {

     $( "#dialog-confirm" ).dialog({
      autoOpen: false});


});

关于javascript - 对话框未打开 ajax jquery MVC2 asp.net,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20367864/

相关文章:

JavaScript:页面加载时间

javascript - Nodejs getTime() 只显示执行时间

jQuery触发新添加的html代码

asp.net - 在日志文件中 : s c sc cs? 是什么意思

javascript - 如何使范围 slider 同时适用于数字和颜色?

javascript - 如何通过同时创建和循环遍历 2 个数组来找到公倍数,javascript

jquery - 鼠标悬停/鼠标离开 : 3rd image positioning and toggling on and off

javascript - JS JQuery 高亮插件 toUpperCase 不是函数,导致无限循环

c# - "Control with id could not be located or a different control is assigned to the same ID after postback."错误

.net - dotnet System.Web.Caching.Cache 与 System.Runtime.Caching.MemoryCache