2012-10-18 17 views
0

我正在使用MVC 4的jqueryuihelpers(http://jqueryuihelpers.apphb.com/Docmo/Dialog)。以下代碼來自文檔頁面。jqueryuihelpers對話框triggerclick事件源

<p>@Html.JQueryUI().Button("Click me!", new { id = "triggerButton" })</p> 

@using (Html.JQueryUI().Begin(new Dialog().AutoOpen(false) 
    .TriggerClick("#triggerButton"))) 
{ 
    <p>This dialog is opened with a button.</p> 
    <p>Please click the X at the top right corner to close it.</p> 
} 

在上面的例子中,TriggerClick的選擇器只用於一個按鈕,它工作正常。

如果我有超過1個按鈕,我想使用類選擇器「.button」。

@using (Html.JQueryUI().Begin(new Dialog().AutoOpen(false) 
    .TriggerClick(".button"))) 
{ 
    <p>This dialog is opened with a button.</p> 
    <p>Please click the X at the top right corner to close it.</p> 
} 

在這種情況下,我如何識別哪個按鈕觸發點擊事件,然後打開對話框?

回答

0

在同一頁面上的購物車示例中演示了一種解決方法。

<div id="cart"> 
@{Html.RenderPartial("ShoppingCart");} 
</div> 

@using (Html.JQueryUI().Begin(new Dialog().Title("Remove").AutoOpen(false) 
.ConfirmAjax(".removeLink", "Yes", "No", 
new AjaxSettings() { Method = HttpVerbs.Post, Success = "removeSuccess", Error = "removeError" }))) 
{ 
    <p>Remove the item from your shopping cart?</p> 
} 

它使用類選擇器並回發到服務器並更新部分頁面內容。

這不完全是我想要的。但它可以作爲替代品。