VisualForce、Apex:Repeat,用于 Javascript 数组更新
这是我在 Salesforce 开发板上提出的一个问题的扩展,该问题没有得到太多关注:
我有一个 VisualForce 页面,需要频繁更改以从控制器加载新信息并将该信息嵌入到 Javascript 数组中以供进一步使用。
当前解决方案:我已经成功使用 VisualForce“浏览器技术”,如下所述(在 Wiki 中): http://wiki.developerforce.com/index.php/Using_Browser_Technologies_in_Visualforce_-_Part_1
我用推荐的标签包围了 Javascript array.push:
<apex:repeat value="{!Object}" var="objects">
d.push( {
element1: "{!objects.id}"
})
</apex:repeat>
问题:当整个页面刷新填充时,该数组被正确填充,并且当我使用“下拉菜单”修改对象上的过滤器(在控制器中)时,DOM 会更新(我可以看到页面上放置了新信息),
但是最终 Javascript 数组不会更改它的值除非我在整个页面上调用刷新,这会破坏部分刷新并对用户的系统造成某种冲击。
这个“必要的帖子”问题以前不是问题,即使我在 DOM 更新后直接调用包含此数组填充的 Javascript 函数,Javascript 数组也不会改变(所以我假设它已加载一次基于页面最初回发并且无法更改时 DOM 上的内容
?
this is an extension of a question I asked on the Salesforce developer boards that didn't get much play:
I have a VisualForce page that requires frequent changes to load new information from the controller and embed that information into a Javascript array for further use.
Curent solution: rI've had success using VisualForce 'Browser Technologies' as described here (in the Wiki): http://wiki.developerforce.com/index.php/Using_Browser_Technologies_in_Visualforce_-_Part_1
I surround the Javascript array.push with the recommended tags:
<apex:repeat value="{!Object}" var="objects">
d.push( {
element1: "{!objects.id}"
})
</apex:repeat>
Issue: The array is correctly populated when an entire page refresh populates, and when I use my 'dropdown' to modify the filter on the object (in the controller), the DOM Is updated (I Can see new information being placed on the page),
Ultimately, however, the Javascript array doesn't change it's values unless I call a refresh on the entire page, which sort of defeats the Partial Refresh and is kind of shock to the system for users.
This 'necessary post' issue wasn't a problem before, and even when I directly call the Javascript function that contains this array population after the DOM has been updated the Javascript array doesn't change (So I'm assuming that it's loaded once based on what's at the DOM when the page initially posts back and can't be changed.
Thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想控制数组何时刷新,请将其包装在输出面板中,并将其 id 放入导致数据需要更新的任何内容的重新渲染属性中。当每个 dom 重新更新时,我之前必须使用它来重新附加一些自定义 jQuery 输入侦听器。
If you want to control when your array gets refreshed wrap it in an outputpanel and put its id in the rerender attribute of whatever causes the data to need an update. I had to use this previously to reattach some custom jQuery input listeners when every the dom was re-updated.