Cheers! I am trying to implement popup window with Lightbox_me plugin in my Ruby On Rails application. I have downloaded jquery.lightbox_me.js
, put it to app/assets/javascripts
, add //= require jquery.lightbox_me
in application.js
file, and in home.js.coffee
(I've HomeController) I do stuff like this:
`$(".popup-button").click (e) ->
alert "!!!"
$(".download_layout").lightbox_me centered: true
e.preventDefault()
alert shows normally, but .lightbox_me doesn't work. Whats the problem?
EDIT: application.js
//.......
//= require jquery
//= require jquery_ujs
//= require jquery.lightbox_me
//= require bootstrap
//= require_tree .
Try to stick to the CoffeeScript syntax :
$(document).ready ->
$(".popup-button").click (e) ->
$("#download_layout").lightbox_me
centered: true
e.preventDefault()
EDIT : Don't forget to place this very important string on the top of your .js.coffee
(I have replicated your code on my machine and it works) :
$(document).ready ->
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.