向Ajax中添加行信息.BeginForm确认消息



我有一个有几列的表。第一列包含位置名称,最后一列包含删除按钮。当我单击任何删除按钮时,它当前显示确认消息"您确定要删除位置吗?"我希望确认消息的末尾显示位置名称。

以下是我认为相关的部分:

@using (Ajax.BeginForm("FirstAjax", "Configuration", null, new AjaxOptions()
            {
                Confirm = "Are you sure you want to delete the location:n",
                HttpMethod = "POST",
                OnFailure = "deleteFailed",
                UpdateTargetId = "CustomLocations"
            },
            new { @id = "deleteLocation" }
            ))
            {
<div id="reportTblDiv">
      <table id="CustomLocations">
         <tbody>
             @foreach (var location in Model.LocationList)
                 {
                      <tr>
                           <td class="location">@location.LocationName</td>
                           <td>
<input type="submit" title=@Model.DeleteButton name="@location.LocationId" value="@Model.DeleteButton" />
</td>
</tr>
      }
      </tbody>
  </table>
</div>
}

我如何在模型中访问正确的元素。从以Confirm?

设置第一个的id与第二个的名称相同。在javascript中为提交添加一个句柄来更新确认消息:

<td id=@location.LocationId class="location">@location.LocationName</td>
<td>
    <input type="submit" title=@Model.DeleteButton name="@location.LocationId" value="@Model.DeleteButton" onclick="return btnDeleteClicked(this);"/>
</td>
     <script>
        function btnDeleteClicked(btnObject){
        var tLocation=$(btnObject).attr('name');
        var tCurrentMessage=$("#deleteLocation").data('ajax-confirm');
        $("#deleteLocation").data('ajax-confirm',tCurrentMessage + tLocation);
        return true;
       }
        </script>

最新更新