简体   繁体   English

在对话框加载时执行 JS

[英]Execute JS on dialog onload

I would like to execute some JS function each time my YUI dialog gets loaded.每次加载 YUI 对话框时,我都想执行一些 JS 函数。 I can't do that from body onload because that body tag belongs to parent page.我不能从 body onload做到这一点,因为 body 标签属于父页面。 I tried doing that by adding the function on onContentReady event.我尝试通过在onContentReady事件上添加函数来onContentReady But that works only when the dialog gets loaded for the first time.但这仅在第一次加载对话框时才有效。 Then if I close the dialog and reopen it, it doesn't work;然后如果我关闭对话框并重新打开它,它就不起作用; probably because the content is already ready when the dialog was opened for the first time and hence the function is not called this time.可能是因为第一次打开对话框时内容已经准备好了,因此这次没有调用该函数。

Any idea what can be done to solve this?知道可以做些什么来解决这个问题吗?

I decided to use dialog.changeContentEvent.subscribe to register the JS code I wanted to execute on dialog onload.我决定使用dialog.changeContentEvent.subscribe来注册我想在对话框dialog.changeContentEvent.subscribe执行的 JS 代码。 This isn't exactly equivalent to onload but still suits my requirement.这并不完全等同于 onload 但仍然符合我的要求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM