[英]Concatenate Js inside html
Im using a fancybox here: 我在这里使用fancybox:
@foreach($galleries as $gallery)
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3">
@if($id != null)
<a id="{{$id}}" class="fancybox-buttons img-holder small-img" rel="gallery" title="" data-fancybox-group="button"
href="/storage/galleries/{{$gallery->image}}">
@else
<a id="{{$gallery->id}}" class="fancybox-buttons img-holder small-img" rel="gallery" title="{{$gallery->id}}" data-fancybox-group="button"
href="/storage/galleries/{{$gallery->image}}">
@endif
<img src="/storage/galleries/{{$gallery->image}}" alt="img">
</a>
</div>
@endforeach
I have a fancybox function and the afterload option got a sharing link like this : 我有一个fancybox函数,并且afterload选项有一个像这样的共享链接:
afterLoad : function() {
id = this.title;
this.title =
'<a href="https://twitter.com/intent/tweet?url={{ urlencode(Request::fullUrl())}}/(id variable)" class="btn btn-tw btn-small"><i class="fa fa-twitter right-fa"></i> Share</a>';
}
I want to add this variable id to the href , if there is another workaround with php it would be great too 我想将此变量id添加到href中,如果使用php有另一种解决方法,那也很好
您可以这样添加id
:
'<a href="https://twitter.com/intent/tweet?url={{ urlencode(Request::fullUrl())}}/' + id + '" class="btn btn-tw btn-small"><i class="fa fa-twitter right-fa"></i> Share</a>';
我发现答案是这样的:
'<a href="https://twitter.com/intent/tweet?url={{ urlencode(Request::fullUrl()) }}/'+id+'" class="btn btn-tw btn-small"><i class="fa fa-twitter right-fa"></i> Share</a>'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.