简体   繁体   English

如何通过锚标记将 id 值传递给模式弹出窗口

[英]How to pass an id value through an anchor tag to a modal popup

How can I pass an id value through an anchor tag to a modal popup and display the id value on a field in the modal.如何通过锚标记将 id 值传递给模式弹出窗口并在模式中的字段上显示 id 值。

It depends on how your modal popup works.这取决于您的模态弹出窗口的工作方式。 Since you have not given any information about this, I will describe a few cases:由于您没有提供任何相关信息,我将描述几个案例:

A modal popup operating only in the client-side仅在客户端运行的模式弹出窗口

If your modal does not need any information from the server and is opened by Javascript only, then you will only need to check the functionality it uses, see how options are passed to that modal and how that functionality is being called.如果您的模态不需要来自服务器的任何信息并且仅由 Javascript 打开,那么您只需检查它使用的功能,查看选项如何传递给该模态以及如何调用该功能。 There should be some parameters that you can pass, or options.应该有一些您可以传递的参数或选项。 You can check this and see whether there is already support to do this.你可以检查一下,看看是否已经有支持这样做。 If so, then use your id value and pass it to your modal.如果是这样,则使用您的 id 值并将其传递给您的模态。 If not, then you will need to customize your modal, or use some extension which customizes it in your stead.如果没有,那么您将需要自定义您的模态,或者使用一些扩展来代替您自定义它。

A modal popup opening as a callback to an AJAX call作为 AJAX 调用的回调打开的模态弹出窗口

Assuming that you are sending a POST request via AJAX to the server, in the callback of that request you can simply and effectively tell your modal what the id is.假设您通过 AJAX 向服务器发送 POST 请求,在该请求的回调中,您可以简单有效地告诉您的模态 ID 是什么。 If the id is already known by the client-side, then it's just like in the previous section.如果客户端已经知道 id,那么就像在上一节中一样。 If only the server is aware of the id value, then it could send it back to the client-side as part of the response and from there on you can operate as in the case of client-side only modal handling.如果只有服务器知道 id 值,那么它可以将其作为响应的一部分发送回客户端,然后您就可以像在客户端仅模态处理的情况下一样操作。

A modal popup containing an iframe with a src包含 iframe 和 src 的模态弹出窗口

If you are showing an iframe in the modal, then you can pass a parameter to that iframe via a src如果您在模态中显示 iframe,那么您可以通过 src 将参数传递给该 iframe

In all cases, if the modal is aware of the id, you can use its value in your anchor tag.在所有情况下,如果模态框知道 id,您可以在锚标记中使用它的值。

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

相关问题 通过在锚标记中使用 data-id 属性,使用 jquery 将值传递给模态弹出窗口 - pass value to modal popup using jquery by using data-id attribute in anchor tag 如何将参数值从锚标记传递到jQuery模式窗口? - how to pass parameter value from anchor tag to jquery modal window? 如何将锚标签的data-id值传递给Code-Igniter控制器功能并以数据模式显示结果? - How to pass data-id value of anchor tag to Code-Igniter controller function and show result in data-modal? 将ID传递到定位标记 - Pass an id to anchor tag 如何在模态弹出窗口中获取标签的值 - How to get value of a tag inside modal popup 如何将动态锚标记ID值或类值传递给另一个脚本 - how to pass dynamic anchor tag id value or class value to another script 无法通过Angular JS中的ng-click传递锚标记id值。 获得未定义的价值 - Couldn't able to pass the anchor tag id value through ng-click in Angular JS. Getting undefined value 如何通过使用MVC单击图像从锚标记传递ID值onclick函数? - how to pass ID value onclick function from anchor tag by click on image using MVC? 如何通过html锚标签传递Js变量 - How to pass Js variable through html anchor tag 如何使用MVC将定位标记类ID传递给函数变量? - How to pass anchor tag class Id to a function variable using mvc?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM