0

我正在为 MVC 4 使用 jqueryuihelpers (http://jqueryuihelpers.apphb.com/Docmo/Dialog)。以下代码来自文档页面。

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

在这种情况下,我如何确定哪个按钮触发了单击事件,从而打开了对话框?

4

1 回答 1

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

它使用类选择器并回发到服务器并更新部分页面内容。

这不完全是我想要的。但它可以作为替代方案。

于 2012-10-18T17:36:44.460 回答