7

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.

3
  • 1
    Well a sneaky way would be to pass it down to the Canvas app as a Param...
    – joshbirk
    Feb 27, 2013 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. Mar 1, 2013 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, 2013 at 17:25

1 Answer 1

2

I'm going to point you here:

https://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

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .