2016-12-14 72 views
0

我想在我的mvc應用程序中使用toastr。當我從下載的NuGet我發現這兩個文件 添加到我的腳本文件夾無法獲取toast在我的mvc應用程序中工作

toastr.js 
    toastr.min.js 

我加了js文件給我的佈局頁

<script src="~/Scripts/jquery-1.12.4.min.js"></script> 
    <script src="~/Scripts/toastr.js"></script> 

我現在寫了下面的代碼在我的頁面佈局在腳本部分。 當我運行我的應用程序時,沒有任何反應。我錯過了什麼嗎?

 $(document).ready(function() { 

      displayToastr(); 

     }); 

     function displayToastr() { 
      //alert('yes'); 
      // Display a info toast, with no title 
      toastr.info('Hi Mahedee, This information for you.'); 

      // Display a warning toast, with no title 
      toastr.warning('Hi Mahedee, This the first warning for you!'); 

      // Display a success toast, with a title 
      toastr.success('Yes! You have successfully completed your task!', 'Congratulation for you, Mahedee!'); 

      // Display an error toast, with a title 
      toastr.error('An error occured in the solution!', 'Please contact with system administrator.'); 
     } 
+0

這是我的解決方案。我錯過了css文件,當我添加它時,一切都開始奏效。 – user2320476

回答

0

這應該有效。你確定你的JS路徑是否正常,並且在加載這些js庫之後運行你的代碼?

+0

是的,我做到了。它不工作。我想這應該是一件容易的事情。我的佈局頁面開始時有鏈接。他們需要結束嗎? – user2320476

+0

請爲此創建一個小提琴或提供有效的代碼示例 - 完整的HTML。我使用CDN來源在當地做了一個快速的工作,它工作... – marcinrek

相關問題