I'm learning Ruby on Rails and I'd like to use some unobtrusive javascript to display a modal. When the user clicks on a remote link, it calls an action in one of my controllers that returns the following javascript...
var SM = new SimpleModal({"width":600});
SM.addButton("Action button", "btn primary", function(){
this.hide();
});
SM.addButton("Cancel", "btn");
SM.show({
"model":"modal-ajax",
"title":"Title",
"param":{
"url":"/ajax/url",
"onRequestComplete": function(){ /* Action on request complete */ }
}
});
...but the problem is the code doesn't know what SimpleModal is since that's defined in a separate javascript file. How can I import or reference that SimpleModal code so that my AJAX update can create the SimpleModal object and show it?
Thanks in advance for your wisdom!
在application.js中要求使用简单模态,以便在应用程序中广泛使用
//= require simple_modal
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.