[英]Concatenate Js inside html
我在這里使用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
我有一個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>';
}
我想將此變量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.