2011-08-10 38 views
1
<% Html.Grid(Model.InnerModel.ParamaterDetails) 
      .Empty("No data available") 
      .Columns(column => 
      { 
       column.For(x => x.MinValue).Named("Possible Min Value"); 
       column.For(x => x.MaxValue).Named("Possible Max Value"); 
       column.For(x => x.ScoreValue).Named("Bespoke Score Value"); 
       column.For(x => "<input type='button' name='button' class='btn' id='editOpenDialog' value='Edit' onclick=javascript:editParametersDialog('" + x.ID + "'); />").DoNotEncode(); 
      }).Render(); %> 


<%Html.EndForm(); %> 
<script type="text/javascript"> 
    function editParametersDialog(ID) { 
     // Go back to the server and get the data for the road card timetable 
     $.ajax({ 
      url: "GetDetails", 
      type: "POST", 
      data: "ID=" + ID, 
      dataType: "json", 
      success: function(data) { 
       UpdateEditDialog(data); 
       $('#addEditDialog').dialog('open'); 
      }, 
      error: function(jqXHR, textStatus, errorThrow) { alert(jqXHR); alert(textStatus); } 
     }); 
    } 

    function UpdateEditDialog(data) { 
     $("#MinValue").val(data.MinValue); 
     $("#MaxValue").val(data.MaxValue); 
     $("#ScoreValue").val(data.ScoreValue); 
    } 

    $(document).ready(function() { 
    }); 

</script> 

GetDetails above is in controller 
[AcceptVerbs(HttpVerbs.Post)] 
     public JsonResult GetDetails (int ID) 
     { 
// some code here 
} 

onclick call javascript:editParametersDialog不起作用。它不会被诱发。 任何线索我可能做错了什么。JavaScript不能在mvccontrib网格中工作

我可以找出javascript:editParametersDialog不会变成蓝色,这通常是这种情况。

+0

你的代码看起来不错。什么不被调用? 'editParametersDialog' javascript方法或'GetDetails'控制器操作? –

+0

我检查了Mozilla的JavaScript调试器,代码被唤醒bt失败,打开对话框,出现错误:“对象不支持此属性或方法” –

+0

确定,因此这与您最初询问的内容完全不同。请更新您的问题与相关的细节。看起来你没有包含jQuery UI,或者你没有设置一个对话框到'addEditDialog' DOM元素。 –

回答

0
<div id="addEditDialog" ></div> 

your code is ok but u didn't put 
<div id="addEditDialog"></div> 
in the .aspx page. 

for show dialog box div tag is must. 
$('#addEditDialog').dialog('open'); 
using this code you say div tag is show as popup. 
Do it and try this one again.