我想将简单的模态javascript 库添加到我的 rails 应用程序
在网页上所有js文件都加载成功
<script src="/assets/simple-modal/mootools-core-1.3.1.js?body=1" type="text/javascript"></script>
<script src="/assets/simple-modal/mootools-more-1.3.1.1.js?body=1" type="text/javascript"></script>
<script src="/assets/simple-modal/simple-modal.js?body=1" type="text/javascript"></script>
我试图在咖啡中添加这样的事件:
$(document).ready ->
$("#batch a.accept").live 'click', ->
SM = new SimpleModal(btn_ok: "Alert button")
SM.show
title: "Title"
contents: "Your message..."
有了萤火虫控制台中的这段代码,我得到了
TypeError: $("simple-modal").getElement is not a function
当我尝试像在手册中那样使用 javascript 添加事件时:
window.addEvent("domready", function(e){
/* Alert */
$("#batch a.accept").addEvent("click", function(e){
e.stop();
var SM = new SimpleModal({"btn_ok":"Alert button"});
SM.show({
"title":"Alert Modal Title",
"contents":"Lorem ipsum dolor sit amet..."
});
});
});
我收到了这个错误:
TypeError: $("#batch a.accept").addEvent is not a function
我能做些什么?