如何将对象传递给 Reveal 模态弹出窗口?

如何将对象传递给 Reveal 模态弹出窗口?

问题描述:

我想在我的 Rails 3.0.3 应用程序中使用 Reveal Modal jQuery 插件.

I'd like to use the Reveal Modal jQuery plug-in with my Rails 3.0.3 application.

我想要做的是从父对象的索引页创建一个子对象.现在我有链接将父级的 id 传递给子控制器的新方法,然后打开子级的 new.html.erb ,如下所示:

What I want to do is create a child object from a parent object's index page. Right now I have links that pass the parent's id to the child controller's new method and then open the child's new.html.erb , like this:

<%= link_to 'Add an entry', new_entry_path(:course_id => course.id) %>

我想做的是打开一个包含用于创建新子对象的表单的模式.

What I would like to do is open a modal containing a form for creating a new child object.

Reveal 插件要求链接标签中存在data-reveal-id",例如:

The Reveal plug-in requires "data-reveal-id" be present in the link tag, e.g.:

`<a href="#" data-reveal-id="myModal">Click Me For A Modal</a>`

我如何/如何使用像 link_to 这样的 Rails 辅助函数来做到这一点?

How/can I do this using Rails helper function like link_to?

谢谢!

吉姆

以下会报错:

<%= f.submit  :reveal-id => "myModal" %>

<%= link_to 'Add an entry', new_entry_path(:course_id => course.id),:reveal-id => "myModal" %>

请尝试以下操作:

<%= f.submit  "data-reveal-id" => "myModal" %>

<%= link_to 'Add an entry', new_entry_path(:course_id => course.id),"data-reveal-id" => "myModal" %>

那行得通.