关于 javascript:从其中的元素关闭 jQuery UI 对话框? | 珊瑚贝

Close a jQuery UI Dialog from an element inside of it?


这是一个简单的问题,可能比我想的要简单。

我正在使用 $.ajax() 调用生成的 html 填充 jQuery UI 对话框。在某些情况下,html 包含一个按钮,当单击该按钮时,我想关闭包含对话框。

假设我对使用 $(“#element”).dialog() 指定为对话框的元素一无所知…(即我不知道对话框中的 “#element” 选择器是什么\\’ s 内部内容) – 从在其中单击的元素关闭对话框的最佳方法是什么?


使用 closest()

1
$(this).closest(‘.ui-dialog-content’).dialog(‘close’);
  • 有趣…实际上 .ui-dialog 似乎并不是正确的选择器。对话框排除了一些 div,似乎真正需要调用它的对话框(‘close’)不是”.ui-dialog”……仍在调查……
  • 看起来像 .closest(‘.ui-dialog-content’).dialog(‘close’);是需要的。
  • @Womp,是的, .ui-dialog 元素是jQuery围绕原始内容放置以将其变成对话框的package元素。


类似:

1
2
3
$(‘a.close’).click(function(e) {
    $(this).closest(‘.dialog’).dialog(‘close’);
});

  • 如果元素是嵌套的怎么办?
  • 你写的时候我正在修复我的样本


来源:https://www.codenong.com/2203977/

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_9894.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?