javascript 无法在 mvccontrib 网格中工作

发布于 2024-11-28 23:45:49 字数 1725 浏览 1 评论 0原文

<% 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 不会变成蓝色,而通常情况下是这样。

<% 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
}

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

听风念你 2024-12-05 23:45:49
<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. 
<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. 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文