Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with 3.1: Success Message with undo - from Tips & Tricks
#2
This seems to be part of the problem:
Code:
$(response).find('div.updated').html()
The javascript is not first evaluated! (look in my ajax success response)
The response is just a string, so there exists no DOM element with class "updated".

I temporarily fixed it this way in my plugin, but some core developer could think this through.

Because when you now enter the page directly via the URL you get a hidden hardcoded <div> and one from the js.

Code:
<?php
    if (isset($msg)) {
        if ($canUndo) $msg .= ' <a href="load.php?id=myplugin&undo">' . i18n_r('UNDO') . '</a>'
        ?>
        <script type="text/javascript">
        $(function() {
            $('div.bodycontent').before('<div class="<?php echo $isSuccess ? 'updated' : 'error'; ?>" style="display:block;">'+
            <?php echo json_encode($msg); ?>+'</div>');
            $(".updated, .error").fadeOut(500).fadeIn(500);
        });
        </script>
        <!-- THE DIRTY TEMPORARY FIX -->
        <div class="<?php echo $update ? 'updated' : 'error'; ?>" style="display:none;visibility:hidden;height:0;margin:0;padding:0;border:0;"><?php echo $msg; ?></div>
        <?php
    }
?>
Reply


Messages In This Thread
Problem with 3.1: Success Message with undo - from Tips & Tricks - by Petit Jean - 2012-04-26, 20:19:35



Users browsing this thread: 1 Guest(s)