我的文件:
<script type="text/javascript" src="{{ STATIC_URL }}js/jquery.fancybox-1.3.4.pack.js"></script>
<link rel="stylesheet" href="{{ STATIC_URL }}css/jquery.fancybox-1.3.4.css" type="text/css" media="screen" />
{% include "submission-form.html" with section="photos" %}
<div class="commentables">
{% load thumbnail %}
{% for story in objects %}
<div class="image {% if forloop.counter|add:"-1"|divisibleby:picsinrow %}left{% else %}{% if forloop.counter|divisibleby:picsinrow %}right{% else %}middle{% endif %}{% endif %}">
{% if story.image %}
{% thumbnail story.image size crop="center" as full_im %}
<a rel="gallery" href="{% url post slug=story.slug %}">
<img class="preview" {% if story.title %} alt="{{ story.title }}" {% endif %} src="{{ full_im.url }}">
</a>
{% endthumbnail %}
{% else %}
{% if story.image_url %}
{% thumbnail story.image_url size crop="center" as full_im %}
<a rel="gallery" href="{% url post slug=story.slug %}">
<img class="preview" {% if story.title %} alt="{{ story.title }}" {% endif %} src="{{ full_im.url }}">
</a>
{% endthumbnail %}
{% endif %}
{% endif %}
</div>
</div>
<script>
$(document).ready(function(){
$(".image a").click(function(){
alert($(this).parent().html());
});
$(".image a").fancybox({
title: $(this).attr("alt"),
content: $(this).parent().html()
});
});
</script>
问题是,fancybox 正在加载锚的 href 的 html,而不是我为内容传递的 html,它会正确发出警报。
这是怎么回事?