salesforce - VisualForce, Apex:Repeat, for Javascript array Update - Stack Overflow

this is an extension of a question I asked on the Salesforce developer boards that didn't get much

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): .php/Using_Browser_Technologies_in_Visualforce_-_Part_1

I surround the Javascript array.push with the remended 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?

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./index.php/Using_Browser_Technologies_in_Visualforce_-_Part_1

I surround the Javascript array.push with the remended 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?

Share Improve this question edited May 10, 2011 at 17:09 skaffman 404k96 gold badges824 silver badges775 bronze badges asked Mar 4, 2011 at 0:26 jordan.bauckejordan.baucke 4,32810 gold badges59 silver badges78 bronze badges 2
  • by Partial Refresh do you mean an AJAX call? – Shad Commented Mar 4, 2011 at 0:39
  • Visualforce has a markup ponent called "UpdatePanel" which is rendered as a 'javascript' ajax panel. When the page is rendered and re-rendered that ajax panel is invoked and the information (in this case the Javascript array ponents are reloaded. – jordan.baucke Commented Mar 8, 2011 at 17:45
Add a ment  | 

1 Answer 1

Reset to default 5

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.

<apex:mandButton action="{!something}" rerender="scriptPanel"/>
<apex:outputPanel id="scriptPanel>
  <script>
     d = new Array();
     <apex:repeat value="{!objects}" var="object">
       d.push({
           element1: "{!objects.id}"            
       });
     </apex:repeat>
  </script>
</apex:outputPanel>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744466065a4575523.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信