0

When bootstrap growl is placed at number 1 or number 2, it works fine.

When it is placed at number 3 ... I get the error:

Uncaught TypeError: $.bootstrapGrowl is not a function

<script>

    // 1
    $.bootstrapGrowl('Foo')


    function addDeleteAnswerListener(button, div, id) {

        // 2
        $.bootstrapGrowl('Foo')

        $('#' + button).click(function () {

            $.ajax({
                type: 'DELETE',
                dataType: 'json',
                url: window.location.origin + '/api/Answers/' + id + '?access_token=' + Cookies.get("authorization"),
                success: function (res) {
                    $('#' + div).hide()
                    answerCount();

                    // 3
                    $.bootstrapGrowl('Foo')

                },
                error: function (res) {
                    window.alert(res.responseJSON.error.message)
                }
            })

        })

    }

</script>

How do I call the bootstrap-growl plugin from within the ajax call?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Dakotah North
  • 1,324
  • 12
  • 29

1 Answers1

0

You could try making a dummy global function and calling $.bootstrapGrowl('Foo') within the dummy function.. Just declare it outside the scope of all javascript functions. Like so..

function myGlobalFunction(foo){
    $.bootstrapGrowl(foo);
} 

And then on //3, you can do the following

myGlobalFunction('foo');
Prasun Jajodia
  • 470
  • 3
  • 15