2

我的移动网站有一些多选控件。具有少量项目(5)的多选正常显示,如多选(移动样式/格式),但项目多于 5 的多选在新页面中显示为对话框视图。出于某种原因,X 按钮没有响应并且没有 colse 效果。我应该怎么做才能使 X 按钮起作用?多选代码:

<div class="field ">
        <label for="offices" class="select">
            Office(s):
        </label>
        @Html.ListBoxFor(m => m.Offices, Model.ListOfOffices, new { Multiple = "multiple", data_theme = "a", data_overlay_theme = "c", inline = "true", data_native_menu = "false" })
 </div> 

jQuery代码:

$(".ui-icon-delete").click(function () {
  //$('.ui-dialog').hide(); no effect
  //$('div[data-role="dialog"]').popup("close"); no effect
  //$('div[data-role="dialog"]').dialog("close"); no effect
  //$('ui-dialog').dialog('close'); no effect
  $(this).parent().remove(); // this one close the dialog, but also remove the X button
  });

谢谢!

4

2 回答 2

0

您的对话框应该有一个与之关联的 ID。考虑到您的对话已正确启动,您应该能够:

<div id="dialog">
    <label for="offices" class="select">
        Office(s):
    </label>
    @Html.ListBoxFor(m => m.Offices, Model.ListOfOffices, new { Multiple = "multiple",  data_theme = "a", data_overlay_theme = "c", inline = "true", data_native_menu = "false" })
</div>

关闭:

$(".ui-icon-delete").click(function () {
   $('#dialog').dialog('close');
}
于 2013-02-13T11:34:50.800 回答
0
$("[class=field]").css({ "display" : "none" });

只需使用.css()jQuery 通过添加属性来隐藏该元素/节点display:none

它会做什么?

它将从当前 HTML 树中隐藏该元素/节点,但不会将其删除。

于 2013-02-13T11:40:18.230 回答