Bootstrap alert dismissal not working, rails 3.2

using twitter bootstrap 2.0 with Rails 3.2 (css files in assets/stylesheets, not using less or sass right now) I have an bootstrap styled error or success alert at the top of my screen (based on whether first word of message == "Error". I've added 'bootstrap.js' & 'bootstrap-alert.js' to the assets/javascript folder. Here is the code in my layout: <% flash.each do |name, msg| %> <% if msg[0..4] == "Error" %>
<% else %>
<% end %> × <%= msg %> <% end %> In my assets/javascripts/application.js I have: $(".alert-message").alert() $(".alert-message").alert('close') Not sure I need both? tried with .alert / .alert-error as well. Nothing happens when I click the close symbol, I'm sure I'm missing something very obvious, but I'm new to using JS /w Rails, can't figure this out. In the Chrome JS console I see this error message, which seems to be about bootstrap-alert.js data-api: `Uncaught TypeError: Object [object Object] has no method 'on'` Many thanks for any tips!
Seconds after clicking 'submit' on this question you realise the problem... The problem was caused by having 'jquery.js' and 'jquiery-ui.js' also in the javascripts folder, must be having clashing names/classes. After removing the jquiery files the js error disappeared on loading the page and the alert-dismissal works now... d'oh

以上就是Bootstrap alert dismissal not working, rails 3.2的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏