Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Trying to submit a field value from a popup modal window to my WordPress parent window meta-box.

On my add post page I have a metabox with a field type 'text'.

Meta-box

The id of my 'text' field type input is 'tumble2_kaltura-video'

Next to the metabox text field is a button link which opens up a modal box:

Kaltura popup window

Once I select my video in the modal box, there is a submit button that when clicked will send out a shortcode. Normally this shortcode is sent to the wp-editor

shortcode output to editor What script do I need to use in order to send the shortcode from the modal box to the metabox text field 'tumble2_kaltura-video'?

Here is my kaltura code that is 'in charge' of normally sending the value to the editor. Need to change something in here to target my metabox instead.

https://gist.github.com/3162011

I tried pasting my code in here instead of gist, but no matter how I formatted it, it was always messed up.

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

Use the parent method to pass data back to your meta field.

Create a JS function to handle the passing of data from Thickbox to the meta field:

function foo_interstitial(data){
   $('.form-field-selector').val(data);
}

Add a submit handler to your thickbox instance that passes to the parent.foo_interstitial() function.

$('.thickbox-submit-selector').submit(function(){
    var _value_to_pass = $('.field-to-pass-selector').val();
    parent.foo_interstitial(_value_to_pass);
});
share|improve this answer
    
Hi Brian: I have cut everything down to what I believe is the relevant code: gist.github.com/3162415 the first snippet is in the iframe popup, the second is the parent window with the input area I am trying to populate when the iframe submit button is clicked, the 3rd is the 'value' hat is being passed along with what I think you wanted me to do..... can you see what I am doing wrong there? b.t.w. thanks for the help –  shawn Jul 23 '12 at 7:32
    
WOW, just read your profile.. Totally cool! Something you'll like to hear... this little script is to actually integrate the kaltura video server into our church website for streaming our sermons. I've been on this for days, just prayed about it again a few hrs ago, and here you come along to help... Amazing! –  shawn Jul 23 '12 at 7:45
    
:) Cool. Add the second bit of code to the markup of modal-form.php and see if that works for you :) –  Brian Fegter Jul 23 '12 at 13:44
    
Hi Brian, I added the jQuery 3rd snippet to the modal-form.php and when clicking the submit button, it is not populating the value to the parent window input. Not sure how to troubleshoot it to see what it is actually doing. If I send you link/login would you be able to tell what is wrong by looking? –  shawn Jul 24 '12 at 1:10
    
@shawn Contact me via my website and we'll post the results here. –  Brian Fegter Jul 24 '12 at 1:56
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.