I am struggling to understand how pass a value back to a VF page that contains a Canvas App. If I understand the documentation correctly I need to create a publish event in my app, so I have the following script in my page:
<script type="text/javascript">
function sendValue(someValue) {
Sfdc.canvas.controller.publish({
name: 'myns.sendVal',
payload : {value : someValue}
});
};
</script>
On the VF side I have to subscribe
<apex:canvasApp developerName="myApp" height="1000px" width="1000px"/>
<script>
Sfdc.canvas(function() {
sr = JSON.parse('<%=signedRequestJson%>');
Sfdc.canvas.client.subscribe(sr.client,
{name : 'myns.sendVal',
onData : function (data) {
alert(data.value);
}
});
});
</script>
This is what I have pieced together from the examples I have seen but it does not work. Most likely because all the examples where about doing this in reverse.