Pass datatables column value from iframe to parent
Pass datatables column value from iframe to parent
Hi, I have a datatable which is displayed in an iframe within a parent window. I am using a dynamic tab creator plugin on the parent page and I am successfully passing a click trigger function to open a new tab in the parent window from a click action within the datatable in the iframe. My problem is that when the new tab in the parent page opens (galleryimages100.php) I need it to pass the id (a data column value from the datatable row in the iframe), to the parent page so it can be used in the URL parameter (galleryimages100.php?id='id from iframe datatable row once clicked')
iframe page table column that triggers the new tab open on parent page when <a> clicked
{
data: null,
render: function ( data, type, row ) {
if (row.macleanf.funeral_home == '1') {
return '<a class="yamba-organisation">'+data.macleanf.id+'</a>'}},
function that triggers the dynamic tab to open in the parent page
$('#yamba_overview').on( 'click', 'a.yamba-organisation', function () {
window.parent.$('#yamba-organisation').trigger('click');
} );
Parent page function to open new tab (this opens the new tabe with an iframe inside it.
$("#yamba-organisation").on("click", function () {
nthTabs.addTab({
id: "yamba",
title: 'Yamba Organisation',
content: '<iframe width="100%" frameborder="0" class="iframe" src="galleryimages100.php?id=................."></iframe>' ,
active: true,
allowClose: true,
location: true,
fadeIn: false
})
});
The code as it is works perfectly fine but I am wanting to pass the data which is in column (0) of my table from the iframe back to the parent page to be used in the URL of the next iframe.
Any help would be appreciated
Answers
Sounds like you want to use
window.postMessage
for inter window (frame) communication. Specificallywindow.parent
can be used to refer to the parent window from the child.Allan