javascript在mvccontrib网格中不起作用 [英] javascript not working in mvccontrib grid
本文介绍了javascript在mvccontrib网格中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<% 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调用javascript:editParametersDialog不起作用.它不会被诱发.任何提示我可能做错了什么.
我可以弄清楚javascript:editParametersDialog不会变成BLUE,通常是这种情况.
The onclick call javascript:editParametersDialog does not work. It does not get evoked. Any clues what I might be doing wrong.
I can figure out that javascript:editParametersDialog does not turn BLUE which is normally the case.
推荐答案
.ajax({ url:"GetDetails", 输入:"POST", 数据:"ID ="+ ID, dataType:"json", 成功:功能(数据){ UpdateEditDialog(data);
.ajax({ url: "GetDetails", type: "POST", data: "ID=" + ID, dataType: "json", success: function(data) { UpdateEditDialog(data);
('#addEditDialog').dialog('open'); }, 错误:功能(jqXHR,textStatus,errorThrow){alert(jqXHR); alert(textStatus); } }); } 函数UpdateEditDialog(data){
('#addEditDialog').dialog('open'); }, error: function(jqXHR, textStatus, errorThrow) { alert(jqXHR); alert(textStatus); } }); } function UpdateEditDialog(data) {
(#MinValue").val(data.MinValue);
("#MinValue").val(data.MinValue);
这篇关于javascript在mvccontrib网格中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文