简体   繁体   English

将数据作为HREF链接传递到引导程序模式

[英]Passing data to a bootstrap modal as an HREF link

What I am trying to do is pass an HTML Link attribute into a modal. 我想做的是将HTML Link属性传递给模式。 This solution works great for me: Passing data to a bootstrap modal but rather than simply POST text data I would like for the data to be an HTML Link in full, just like this: 该解决方案对我来说非常有用:将数据传递给引导程序模式 ,而不是简单地将POST文本数据传递给我,我希望数据成为完整的HTML链接,如下所示:

<a href="http://example.com">http://example.com</a>

(please note that the link is on purpose 'a link' as well) (请注意,链接也是故意的“链接”)

At the moment this fiddle works very well (which is also taken from the previous StackOverFlow question) https://jsfiddle.net/k7FC2/ but I am unsure how to change this line to do what I am trying to achieve: 目前,这种提琴效果很好(这也来自上一个StackOverFlow问题) https://jsfiddle.net/k7FC2/但我不确定如何更改此行以实现我要实现的目标:

So I would like to change this Javascript line: 因此,我想更改此JavaScript行:

<input type="text" name="bookId" value=""/>

and I would like to change that so it 'echoes' the value of an HTML Link (which is hotlinked) rather than just the text data as illustrated in the fiddle... 并且我想更改它,使其“回显” HTML链接(热链接)的值,而不是像小提琴中所示的那样只是文本数据...

Any ideas? 有任何想法吗?

Thanks!! 谢谢!!

You will have something like this in the modal: 您将在模式中看到以下内容:

<a href="" id="myLink"></a>

Then you can use the Javascript code from jsFiddle that you have provided, changing this: 然后,您可以使用提供的jsFiddle中的Javascript代码,进行以下更改:

$('#my_modal').on('show.bs.modal', function(e) {
    var myURL = 'http://someurladdress';
    $(e.currentTarget).find('#myLink').prop('href', myURL);
});

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM