2012-12-08 69 views
0

我有一個自定義的列劍道UI格爲這樣:添加一行返回

columns.Template(@<text></text>) 
       .Width(50) 
       .ClientTemplate("#= getDeleteHTML(Id, DisplayLocation) #"); 

它調用一個js函數來構建HTML注入的形式提交了刪除:

function getDeleteHTML(itemId, itemName) { 
     var deleteHtml = "<form action='"+ '@Url.Action("Delete", "ManageLocations")'+"/" + itemId +"' method='post'>" 
          + "<input type='image' onclick='return confirm(\"Are you sure you wish to delete: \r\n" + itemName + "?\");' value='Delete' class='delete' src='../Images/transparent.gif'>" 
         + "</form>"; 
     return deleteHtml; 
    } 

我想打破確認消息爲2行。我試過\ r \ n和@ Environment.NewLine + itemName,因爲我不確定在這種情況下使用哪個分析器(客戶端或服務器)。

我該如何做到這一點?

+0

可能重複http://stackoverflow.com/questions/1841452/new-line-in-javascript-警報框) –

回答

1

您是否嘗試過移動確認到另一個功能

function getDeleteHTML(itemId, itemName) { 
     var deleteHtml = "<form action='"+ '@Url.Action("Delete", "ManageLocations")'+"/" + itemId +"' method='post'>" 
      + "<input type='image' onclick='confirmDelete(" + itemName + ")' value='Delete' class='delete' src='../Images/transparent.gif'>" 
      + "</form>"; 
     return deleteHtml; 
    } 

function confirmDelete(itemName) { 
    return confirm("Are you sure you wish to delete: \n" + itemName + "?"); 
} 
[在JavaScript警告框,新線(的
+0

謝謝弗拉德。這工作。 –