简体   繁体   English

如何使用Ruby on Rails创建类似这样的模式弹出窗口?

[英]How do I create a modal popup like this using Ruby on Rails?

I want to get a modal popup almost like the ones you see when you send a message on Facebook or when you sign up to say the newsletter on www.gemvara.com in my own Ruby on Rails application. 我想要一个模态弹出窗口,就像您在Facebook上发送消息时或在我自己的Ruby on Rails应用程序中注册在www.gemvara.com上说新闻通讯时看到的弹出窗口一样。

The idea is someone signs up for a newsletter, and I give them a very friendly inline modal popup saying thanks for subscribing, etc. 这个想法是有人签了一个新闻通讯,我给他们一个非常友好的内联模式弹出窗口,说谢谢您的订阅,等等。

How do I go about doing that with Ruby on Rails? 我该如何使用Ruby on Rails做到这一点? Do I have to use ActionView? 我必须使用ActionView吗? Do I write it in pure JavaScript and not bother doing it in Rails? 我要用纯JavaScript编写它,而不用在Rails中这样做吗? How do you Rails experts suggest I do this the cleanest way possible using Rails 2.3.8. 您如何使用Rails专家建议我使用Rails 2.3.8尽可能做到最简洁。

I've found plugins that does this in jQuery, does that mean I should load jQuery AND Prototype which is Rails default javascript library of choice? 我已经找到在jQuery中执行此操作的插件,这是否意味着我应该加载jQuery AND Prototype,这是Rails默认的javascript库? Seems like a waste of network bandwidth to load both. 加载两者似乎浪费了网络带宽。

Modal dialogs are accomplished via JavaScript. 模态对话框是通过JavaScript完成的。 Your rails app may provide the data, form, whatever that is displayed in the dialog, but you are doing a lot of the work in JavaScript. 无论您在对话框中显示什么,Rails应用程序都可以提供数据,表单,但是您正在JavaScript中做很多工作。 I would recommend taking a look @ the jQuery UI project. 我建议看看@ jQuery UI项目。 Here is a link directly to their modal dialog widget: http://jqueryui.com/demos/dialog/ 这是直接链接到其模式对话框小部件的链接: http : //jqueryui.com/demos/dialog/

Have fun! 玩得开心!

另外,如果您不使用jQuery,则有一个名为Redbox的rails插件,尽管我已经有一段时间没有使用它了,但是如果您使用的是默认JS,它还可以创建模态并使用Prototype。库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Ruby on Rails中使用Evernote gem创建注释? - How do I create a note using the Evernote gem in Ruby on Rails? 如何在按钮单击时显示 Ruby Rails Form Modal 弹出窗口? - How to show Ruby Rails Form Modal popup on button click? 如何创建一个使用Ruby on Rails将字符串输入表单的按钮? - How do I create a button that enters a string into a form using Ruby on Rails? 如何为我的应用程序创建Twitter样式的URL-使用现有应用程序或重新设计应用程序-Ruby on Rails - How do I create Twitter style URLs for my app - Using existing application or app redesign - Ruby on Rails 如何创建按某些属性对表格进行排序的按钮? 我正在使用Ruby on Rails - How do I create a button to sort a table by certain attributes? Im using Ruby on Rails 如何使用URL链接到Ruby on Rails中的create操作? - How do I use a URL to link to the create action in Ruby on Rails? 如何在rails上的ruby中创建facebook样式的新闻源? - How do I create a facebook style news feed in ruby on rails? 如何在Ruby on Rails中创建自定义路由-4.2 - How do I create custom routes in Ruby on Rails - 4.2 如何通过单击Rails上的ruby上的图像来创建类别 - How do I create a category by clicking on an image on ruby on rails Ruby on Rails-如何创建传递参数的网址? - Ruby on Rails - how do I create a url to pass a parameter?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM