JQuery Dialog删除状态图像

时间:2011-12-14 23:40:49

标签: jquery jquery-ui jquery-ui-dialog

我在jQuery对话框中有密码表单。提交表单后,我需要删除该图像,但这似乎不起作用。谁能告诉我怎么做呢?

这是对话框的HTML:

<div class="ui-dialog-buttonpane ui-widget-content ui-helper-clearfix">
<div class="ui-dialog-buttonset">
<button class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only ui-state-hover" type="button" role="button" aria-disabled="false">
<span class="ui-button-text">Retrieve it</span>
</button>
<button class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" role="button" aria-disabled="false">
<span class="ui-button-text">Cancel</span>
</button>
</div>
<img id="password-status" class="progressStatus" title="Status" alt="Status" src="/Content/alert/progress.gif" style="">
</div>

这就是我在做的事情:

$("#password-status").remove().fadeOut();

另一次尝试:

 $(".ui-dialog-buttonpane").remove($("#password-status").fadeOut());

1 个答案:

答案 0 :(得分:0)

如果您实际使用的是an HTML form submit,则会刷新该页面,因此您无需删除。在使用表单提交查看页面时,不要添加服务器端代码。您将在PHP或ASP代码(或您正在使用的任何服务器端技术)中执行此操作。

如果您使用的是AJAX而不是HTML表单,请尝试将id添加到每个按钮,并通过jQuery绑定click事件。

这是a fiddle demonstrating this

修改了您的HTML以添加id s:

<div class="ui-dialog-buttonpane ui-widget-content ui-helper-clearfix">
  <div class="ui-dialog-buttonset">
    <button id="retrieve-button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only ui-state-hover" type="button" role="button" aria-disabled="false">
      <span class="ui-button-text">Retrieve it</span>
    </button>
    <button id="cancel-button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" role="button" aria-disabled="false">
      <span class="ui-button-text">Cancel</span>
    </button>
  </div>
  <img id="password-status" class="progressStatus" title="Status" alt="Status"
       src="/Content/alert/progress.gif">
</div>

JS在点击时禁用图像:

$("#retrieve-button").click(function() {
    // Todo: Add submit https AJAX call here, and bind success to removeImages.
    // For now, we'll just call it directly
    removeImages();
});

function removeImages() {
    $("#password-status").remove().fadeOut();
}
相关问题