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.

I'm trying to implement a "publish" button from a custom post type metabox. Everything actually works fine if I either create a new button and manually call submit() or duplicate the regular submit buttons, except for one thing: if i change the title of the post, I always get the "Confirm Navigation" popup asking me if I want tstay or leave the page. It doesn't do this when using the regular "Update" button though, so there's gotta be a way to stop it, I just can't seem to get a handle on it.

Custom save button using a link:

<a href="#" id="saveChangesButton" class="button-primary alignright">Save</a>

// in ready()
$('#saveChangesButton').live('click', function() {
        $('#saveChangesButton').addClass('button-primary-disabled');
        $('#post').submit();
        return false;           
});

Custom save buttons trying to mimic the submitdiv's buttons:

<?php if ($_GET['action'] == 'edit') : ?>
    <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Save') ?>" />
    <input name="save" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="Update">

<?php else: ?>
    <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Publish') ?>" />

    <input name="publish" type="submit" id="publish" class="button-primary" value="Publish" tabindex="5" accesskey="p">
<?php endif; ?>
share|improve this question
    
Post some relevant code along with your questions, please. –  soulseekah Oct 21 '11 at 5:54
    
added code samples. Either way I create the buttons, if I change the post's title, I get the "Confirm Navigation" dialog when trying to save. –  flashape Oct 21 '11 at 17:46
    
Have you seen exactly how the publish link originally works? core.trac.wordpress.org/browser/tags/3.2.1/wp-admin/includes/…, I don't see how your code comes close to this. Are you creating those metaboxes with the add_meta_box() function? –  soulseekah Oct 21 '11 at 18:41
    
All I wanted to do was submit the post from a secondary button, not recreate the entire process. I worked around the issue by disabling autosave for my custom post type and it works fine now. –  flashape Oct 21 '11 at 19:48

1 Answer 1

up vote 0 down vote accepted

You can stimulate click to Update post button like this.. Adding submit or update button to custom metabox?

<script>
jQuery('.metabox_submit').click(function(e) {
    e.preventDefault();
    jQuery('#publish').click();
});
</script>
<input type="submit" class="metabox_submit" value="Submit" />
share|improve this answer
    
that is actually what I wound up doing....way simpler. –  flashape Apr 23 '12 at 18:47

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.