Skip to content

Instantly share code, notes, and snippets.

@anointed
Created July 23, 2012 07:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anointed/3162415 to your computer and use it in GitHub Desktop.
Save anointed/3162415 to your computer and use it in GitHub Desktop.
passing value from iframe modal to parent window
<?php
<form action="/wp-admin/media-upload.php?tab=kaltura_upload&amp;kaction=sendtoeditor&amp;firstedit=true&amp;entryIds%5B0%5D=0_715ta6uz" class="kalturaForm" method="post">
<input type="submit" class="button-secondary" name="tumble2_kaltura-video" value="Add Video">
</form>
?>
<table class="form-table">
<tbody>
<tr>
<td>
<input type="text" size="30" value="" id="tumble2_kaltura-video" name="tumble2_kaltura-video">
<a title="Add Video" class="thickbox visible" href="media-upload.php?post_id=148&amp;tab=shawn_upload&amp;TB_iframe=true&amp;width=640&amp;height=97">
<img alt="Add Video" src="http://zurb.dev/wp-content/plugins/all-in-one-video-pack/images/interactive_video_button.gif">
</a>
</td>
</tr>
</tbody>
</table>
<script type="text/javascript">
var playerWidth = "<?php echo $viewData["playerWidth"]; ?>";
var playerHeight = "<?php echo $viewData["playerHeight"]; ?>";
var uiConfId = "<?php echo $viewData["uiConfId"]; ?>";
var entryId = "<?php echo $viewData["entryId"]; ?>";
var addPermission = "<?php echo $viewData["addPermission"]; ?>";
var editPermission = "<?php echo $viewData["editPermission"]; ?>";
var htmlArray = [];
htmlArray.push('[');
htmlArray.push('kaltura-widget ');
htmlArray.push('uiconfid="'+uiConfId+'" ');
htmlArray.push('entryid="'+entryId+'" ');
htmlArray.push('width="'+playerWidth+'" ');
htmlArray.push('height="'+playerHeight+'" ');
htmlArray.push('addpermission="'+addPermission+'" ');
htmlArray.push('editpermission="'+editPermission+'" ');
htmlArray.push('/]');
htmlArray.push('\n');
var html = htmlArray.join('');
function foo_interstitial(data){
jQuery('.kalturaForm').val(data);
}
jQuery('.button-secondary').submit(function(){
var _value_to_pass = $('.tumble2_kaltura-video').val();
parent.foo_interstitial(html);
});
</script>
@anointed
Copy link
Author

Scenario:
I have a submit button in an iframe -- relevant code is the modal-form.php
When I click the submit button in the iframe, I want to take the output of [ value-being-passed-to-parent.js ] the 3rd snippet and pass that to the parent window input [the second snippet]

@anointed
Copy link
Author

If I have missed any relevant code by using short snippets, then here is a link to the full code for both the iframe, and the parent window:
https://gist.github.com/3162011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment