simplemodal 从调用元素传递附加参数

发布于 2024-09-26 01:26:24 字数 189 浏览 0 评论 0原文

我正在尝试设置一个页面,为一群人呈现一个带有时间序列的网格。本质上是一个日历,其中行表示特定时间,列表示与之相关的人员。

我打算在用户单击某个时间时打开一个模式对话框并通过 AJAX 加载当前数据。这与联系表单示例非常相似,当然,在单击链接之前我不会知道时间和人员。所以我想要一种方法将这些额外的数据传递给对话框调用脚本。

非常感谢

I am trying to set up a page that presents a grid with a sequence of times on it for a group of people. Essentially a calendar with rows for a specific time and columns for the person it relates to.

I intend to have a modal dialog box open when a user clicks on a time and load the current data via AJAX. This is very similar to the contact form example except of course that I will not know what the time and person are until the link is clicked. So I would like a way to pass this extra data to the dialog calling script.

Many thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

猫性小仙女 2024-10-03 01:26:24

实现此目的的一个好方法是 HTML5 中新的 data- 属性。不用担心,所有浏览器都支持它们。

如果您的额外数据是时间和人员,您的链接将如下所示:

<a href="#" data-time="2011-01-01 11:11:11" data-person="John Smith">...</a>

您可以在 javascript 函数中访问此数据:

var link = this,
    time = link.getAttribute("data-time"),
    person = link.getAttribute("data-person");

A nice way of doing this is the new data-attributes in HTML5. Not to worry, they are supported by all browsers.

If your extra data is time and person, your link would look like this:

<a href="#" data-time="2011-01-01 11:11:11" data-person="John Smith">...</a>

And you can access this data in the javascript-function:

var link = this,
    time = link.getAttribute("data-time"),
    person = link.getAttribute("data-person");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文