Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

想請教一下,如何讓這個Alert訊息過幾秒後自動消失? #33

Closed
afgnsu opened this issue Oct 5, 2015 · 7 comments
Closed

Comments

@afgnsu
Copy link

afgnsu commented Oct 5, 2015

如題, 我有看到網路上建議用 $(".alert").fadeOut(3000) ,放在 app/assets/javascripts/XXX.coffee ,可是好像沒用 >"<

2015-10-05 21 48 33
2015-10-05 21 52 10

@zackexplosion
Copy link
Member

注意執行的順序,不知道你在哪裡執行 fadeOut 的 function

@afgnsu
Copy link
Author

afgnsu commented Oct 5, 2015

我只是用 Rails 101s 的範例
http://github.com/afgnsu/rails101s

@JuanitoFatas
Copy link
Contributor

/cc @sdlong

@chinghanho
Copy link
Member

兩個方式

  1. 把載入 script 的 tag 放到 <body> 最後面
  2. 把 callback 放在 document ready 內:
$(function() {
  $(".alert").fadeOut(3000)
})

@afgnsu
Copy link
Author

afgnsu commented Oct 6, 2015

我用的是 <% bootstrap_flash %>

我把

<script type='javascript/text'> $(function() { $(".alert").fadeOut(3000) }) </script>

放到 app/views/layouts/application.html.erb 的 上面,不知道為何沒反應 >"<

2015-10-06 1:39 GMT+08:00 Ching-Han Ho notifications@github.com:

兩個方式

  1. 把載入 script 的 tag 放到 最後面
  2. 把 callback 放在 document ready 內:

$(function() {
$(".alert").fadeOut(3000)
})


Reply to this email directly or view it on GitHub
#33 (comment).

◢▄◣ 蘇介吾 / 家住楊梅市新農街
○○█ Mobile: 0921-380997
◥○◤ Email : afgnsu@gmail.com
▂██ FB: http://fb.me/afgnsu
▂█◤ Website : afgn.idv.tw

@SDLyu
Copy link

SDLyu commented Oct 6, 2015

<script type='javascript/text'>type 宣告錯了,應該寫成下面這樣

  1. <script type='text/javascript'>...</script>
  2. <script>...</script>

任意一種都可以

@afgnsu
Copy link
Author

afgnsu commented Oct 6, 2015

SDLyu 可以了,謝謝 ^_^

@afgnsu afgnsu closed this as completed Oct 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants