Jquery 如何设置fotorama插件以动态生成图像?
我使用jquery,我在head标签中添加了Jquery 如何设置fotorama插件以动态生成图像?,jquery,django,Jquery,Django,我使用jquery,我在head标签中添加了 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <link href="http://fotorama.s3.amazonaws.com/4.5.2/fotorama.css" rel="stylesheet"> <script src="http://fotorama.s3
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link href="http://fotorama.s3.amazonaws.com/4.5.2/fotorama.css" rel="stylesheet">
<script src="http://fotorama.s3.amazonaws.com/4.5.2/fotorama.js"></script>
$(document).ready(function($)
{
$.get( "getonepoi",{clicked:clicked_poi}, function(data)
{
$( "#picture_bar" ).html(data.picture_bar);
$('#dialog').dialog('option', 'title', clicked_poi);
$( "#dialog" ).dialog( "open" );
});
});
然后用幻灯片演示fotorama,head中包含的jquery插件不起作用,但当我手动添加代码时
<div id="dialog" title="Basic dialog">
<div class="fotorama" id ="picture_bar">
img src="http://s.fotorama.io/1.jpg">
</div>
</div>
img src=”http://s.fotorama.io/1.jpg">
然后它工作了,有人知道为什么在$get中添加html不想包含其他js、css,当我单击Inspect元素时,一切看起来都很好,这里我删除了脚本和img标记的First字符,因为stackoverflow显示的是图像而不是代码,所以错误不是因为“请参见,尝试将js代码放在HTML代码的页脚中,以确保所有DOM都已准备就绪并由浏览器加载。试试这个。。。
$(窗口).load(函数(){
变量图片_条=“”;
$(“#图片栏”).html(图片栏);
});代码>
picture_bar='img src="http://s.fotorama.io/1.jpg">'
$( "#picture_bar" ).html(data.picture_bar);
<div id="dialog" title="Basic dialog">
<div class="fotorama" id ="picture_bar">
img src="http://s.fotorama.io/1.jpg">
</div>
</div>
def get_one_poi(request):
if "clicked" in request.GET:
poi_name=request.GET["clicked"]
pictures=Pic.objects.filter(poi_id=poi_name)
picture_bar=""
for picture in pictures:
picture_bar+='<img src="http://127.0.0.1:8000/media/'+str(picture.picture)+'">'
picture_bar+='<img src="http://s.fotorama.io/2.jpg">'
print picture_bar
response_data = {}
response_data['picture_bar'] = picture_bar
return HttpResponse(json.dumps(response_data), content_type="application/json")