2

I like this jquery script to load on pageload instead of load on click. I changed the following:

<script>
    $('.error').on('click', function(){
        $(this).notifyMe(
            'bottom', // Position
            'error', // Type
            'Lorem Ipsum Text', // Title
            'Lorem Ipsum is simply dummy text of the printing', // Description
            200 // Velocity of notification
        2000 // (optional) Time of delay to close automatically
        );
    });
</script>

to:

<script>
    $(document).ready(function() {
        $(this).notifyMe(
            'bottom', // Position
            'error', // Type
            'Lorem Ipsum Text', // Title
            'Lorem Ipsum is simply dummy text of the printing', // Description
            200 // Velocity of notification
        2000 // (optional) Time of delay to close automatically
        );
    });
</script>

But it doesn't load the notifyer. It's based on this script: http://www.jqueryrain.com/?koLHvt8W

Can somebody tell me what I did wrong?

Nick Tomlin
  • 28,402
  • 11
  • 61
  • 90
user3303790
  • 137
  • 5
  • 4
    Your `this` refers to different objects. Change it to `$(".error")` in the second version to keep it consistent. Also remember that [*page load* and *document ready* are not the same](http://stackoverflow.com/questions/3698200/window-onload-vs-document-ready) – blgt Dec 19 '14 at 16:57

1 Answers1

1

Should be:

$(document).ready(function () {
    $('.error').notifyMe(
        'bottom', // Position
    'error', // Type
    'Lorem Ipsum Text', // Title
    'Lorem Ipsum is simply dummy text of the printing', // Description
    200 // Velocity of notification
    2000 // (optional) Time of delay to close automatically
    );
});
Sam Battat
  • 5,725
  • 1
  • 20
  • 29