Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Ok, here is the setup:

  • I've a Canvas App with a select in it;
  • I've a Visualforce page with a selectList element filled with the same options as the select in the Canvas App, and a canvasApp element that points to the previously mentioned Canvas App.

Now I need to be able to synchronize the contents of the selectList with the select.
From everything I've read and experimented I'm concluding that the only way to do this is by using a somewhat messy javascript. So I was just wondering if anyone out there has a better idea on how to do this.

Thanks.

share|improve this question
1  
Well a sneaky way would be to pass it down to the Canvas app as a Param... –  joshbirk Feb 27 '13 at 18:46
    
I guess that by refreshing the whole canvas app I could keep it synchronized, but what about the other way around? How do you suggest that I keep the visualforce selectList synchronized with the select inside the canvas app? ... Again, keeping it simple. –  ricardomartins Mar 1 '13 at 12:26
    
Canvas talks to Salesforce by sending messages to the window, and then having those messages proxied back to the API's. So you would need to do it via REST somehow. Custom Apex endpoint, perhaps. –  joshbirk Mar 1 '13 at 17:25
add comment

1 Answer

I'm going to point you here:

http://stackoverflow.com/questions/3800309/using-postmessage-to-refresh-iframes-parent-document

I've just implemented it myself with a Canvas app and it works fine.

window.addEventListener('message', receiveMessage, false);

function receiveMessage(evt)
{
  if (evt.origin === 'https://my.cavasapp.com')
  {
     //Code to process message and sync select box here.
     //alert("got message: "+evt.data);
  }
}

Note the browser limitations here (IE won't allow a JSON object it seems): http://caniuse.com/x-doc-messaging

share|improve this answer
    
Just what I was looking for - thanks Steven. –  Bob Buzzard Dec 12 '13 at 9:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.