Created
July 23, 2012 07:25
-
-
Save anointed/3162415 to your computer and use it in GitHub Desktop.
passing value from iframe modal to parent window
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
<form action="/wp-admin/media-upload.php?tab=kaltura_upload&kaction=sendtoeditor&firstedit=true&entryIds%5B0%5D=0_715ta6uz" class="kalturaForm" method="post"> | |
<input type="submit" class="button-secondary" name="tumble2_kaltura-video" value="Add Video"> | |
</form> | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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&tab=shawn_upload&TB_iframe=true&width=640&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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
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
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]