区域组件更改 Tapestry 5 中其他组件的 ID
我在区域内有一个 from 和其他组件。每当区域刷新时,它也会更改表单组件和其他组件的 ID。我在 JavaScript 中使用组件的 id,因此面临问题,因为区域更改了 ID。
有什么方法可以阻止 Tapestry 5 中区域的这种行为吗?
提前感谢各位。
问候,
I have a from and other components inside the Zone. whenever Zone get refreshed it change the ID of form component and other components too. I am using the id of components in JavaScript so facing problem because Zone changes the IDs.
is there any way to stop this behavior of Zone in Tapestry 5.
Thanks in Advance guys.
Regards,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简而言之,不。当从 AJAX 请求返回内容时,根据设计,ID 可以是任何内容。
更长的答案是,您可能应该以不同的方式构建代码,并根据区域的内容创建一个组件:
然后,确保使用该新组件中的实际客户端 ID 初始化 JS:
的模板:
以及新组件 这样,您将组件的实际客户端ID传递给Javascript初始化程序,从而在每次重新加载区域内容时重新初始化JS。
In short, no. When content is returned from an AJAX request, by design, the IDs can be anything.
The longer answer is that you should possibly structure your code differently and create a component from the contents of the Zone:
Then, make sure you initialize your JS with the actual client ID in that new component:
And the template for the new component:
That way, you're passing the actual client ID of your component to your Javascript initializer, thus re-initializing the JS every time the content of your Zone is reloaded.