如何在我的Symfony应用程序中安装boostrapGrowl?

时间:2016-02-22 07:56:38

标签: javascript jquery twitter-bootstrap symfony

我想将BootstrapGrowl library安装到我的Symfony2应用程序中。我试着做

composer require bootstrap-growl
composer install

它已经在/ vendor /目录中安装了库,但是我不知道如何使用它,因为当我尝试在我的JS代码中调用它时,比如

$.bootstrapGrowl("Message");

我在控制台中收到以下错误:

Uncaught TypeError: $.bootstrapGrowl is not a function

我也试过将这个文件包含在我的layout.html.twig文件中,但这是不可能的 - 我从IDE中得不到任何提示。我该如何正确地做到这一点,以便我可以在我的项目中使用该库?

1 个答案:

答案 0 :(得分:0)

将依赖项和 jquery.bootstrap-growl.min.js 纳入您的网页并调用以下内容:

$.bootstrapGrowl("My message");

不要忘记包含jquery和bootstrap

可用选项

默认情况下,咆哮使用标准的“警报”Bootstrap样式,宽250像素,右对齐,距离页面右上角20px。

$.bootstrapGrowl("another message, yay!", {
  ele: 'body', // which element to append to
  type: 'info', // (null, 'info', 'danger', 'success')
  offset: {from: 'top', amount: 20}, // 'top', or 'bottom'
  align: 'right', // ('left', 'right', or 'center')
  width: 250, // (integer, or 'auto')
  delay: 4000, // Time while the message will be displayed. It's not equivalent to the *demo* timeOut!
  allow_dismiss: true, // If true then will display a cross to close the popup.
  stackup_spacing: 10 // spacing between consecutively stacked growls.
});