• Hello everybody!

    I’d like to have a confirm dialog if somebody clicks on “move_to_trash”.

    Right now I am able to react to the click with the help of JQuery and can interrupt the “move_to_trash” process with either an alert or a confirm() message.

    function confirm_delete() {
            ?>
            <script language="javascript">
            var $j=jQuery.noConflict();
            $j(document).ready(
                    function(){
                            $j("a.submitdelete").click(function(){
    
                                    return confirm("Do you really want to...")
                                    });
                            $j("#submitpost #ajax-loading, #submitpost .ajax-loading").hide()
                            }
                    );
            </script>
            <?php
    }

    Thats how the function is called:
    add_action('admin_footer', array($this, 'confirm_delete'));

    The problem is that I need other buttons than “OK” and “Cancel” and therefore the JQuery modal dialog came to my mind.

    Unfortunately I was not able to realize it within wordpress. The dialog will not display at all which might be due to my non-existing JQuery skills.

    Any help is appreciated!

    Best regards,
    Stefan

Viewing 1 replies (of 1 total)
  • Thread Starter stefan2k

    (@stefan2k)

    For those searching… it works like this:

    var $j=jQuery.noConflict();
    
    			$j(document).ready(function(){
    
    				$j('a.submitdelete').click(function(e){		
    
    					e.preventDefault();
    
    					$j("#confirm-dialog").dialog({
    						resizable: false,
    						height:200,
    						modal: true,
    						buttons: {
    							"Button1": function() {
    								$j( this ).dialog( "close" );
    
    							},
    							"Button2": function() {
    								$j( this ).dialog( "close" );
    
    							}
    						}
    					}).show();
    				});
    
    			});

    And of course you need a div somewhere in your wordpress page.

    In the end this approach didn’t work out for me as in the post overview the dialog didn’t show up… because, right, there is no div in the post overview page ??

Viewing 1 replies (of 1 total)
  • The topic ‘Move_to_trash confirm JQuery dialog’ is closed to new replies.