【问题标题】:Link behaviour in Datatables row not behaving the same as link outside of datatables数据表行中的链接行为与数据表外的链接行为不同
【发布时间】:2019-02-03 06:30:47
【问题描述】:

我的数据表中有一行显示一个带有行 ID 的 url。当您单击该链接时,它应该打开一个模式窗口并加载 URL。然而,由于某种原因,它只是重定向到一个新页面并显示应该在模式窗口中的表单。

当我访问位于数据表外部的同一链接时,模式窗口会打开并正确加载 url。

属性 rel = "modal:open" 是打开模态窗口的属性。这是我正在使用的 jquery 模态库https://github.com/kylefox/jquery-modal

我不太清楚为什么相同的链接会有不同的行为。

这是我的代码

正常工作的链接:

@Html.ActionLink("Add", "RoleDetails", @ViewContext.RouteData.Values["controller"].ToString(), null, new { @class = "btn btn-default pull-right", @rel = "modal:open" })

重定向到另一个页面的数据表中的链接:

"columns": [
        {
            "data": function (data, type, row, meta) {
                 var url = "@Url.Action("RoleDetails", @ViewContext.RouteData.Values["controller"].ToString())" + data.Id;
                 return "<a href=" + url + " rel=\"model:open\">" + data.Name + "</i></a>"
            }, "name": "Name" 
        },
    ],

或者有没有办法在数据表 url 上使用 @Html.ActionLink?我不确定缺少什么。

【问题讨论】:

    标签: javascript c# jquery asp.net datatables


    【解决方案1】:

    所以事实证明我应该对我的 rel 属性这样做

    rel='modal:open'
    

    我设法让它像这样工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-09
      • 2013-08-17
      • 1970-01-01
      • 2017-06-09
      • 2021-02-27
      • 1970-01-01
      相关资源
      最近更新 更多