对话框没有打开ajax jquery MVC2 asp.net

时间:2013-12-04 05:45:39

标签: 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);`

控制器:      public string delete_marker(string Id)      {        尝试         {                 mapmaker_dbDataContext DB = new mapmaker_dbDataContext();                 DB.SP_DeletePoint(Id,/ &#34; Innayat&#34; / User.Identity.Name);                 返回&#34;点成功删除&#34 ;;         }         catch(Exception exc)           {                 返回&#34;删除操作失败&#34 ;;           }         }

删除功能:

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 functionlity再次给出错误

1 个答案:

答案 0 :(得分:0)

在加载主体或文档上声明对话框div,如下所示......

$(function() {

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


});