0

我想为表格中的每个元素设置一个“发送邮件”按钮,一旦用户单击它,应该会弹出一个内部表单和一个按钮。我尝试将 jquery 用于弹出窗口,但它不起作用,有人可以告诉我我做错了什么或建议我以任何其他方式创建此弹出窗口。目前我正在使用 twitter 引导模式,但想用弹出/弹出窗口替换它

homepage.html

        <table id="search-results" class="table table-hover">
        </table>

    ajax.js

        $(function(){

            $('#searchtest').click(function() {

                $.ajax({
                    type: "POST",
                    url: "/searchtrips/",
                    data: {
                        'city' : $('#city').val(),
                        'location' : $('#location').val(),
                        'duration' : $('#duration').val(),
                        'search_text' : $('#searchtest').val(),
                        'csrfmiddlewaretoken' : $("input[name=csrfmiddlewaretoken]").val()
                    },
                    success: searchSuccess,
                    dataType: 'html'
                });

            });

        });

        function searchSuccess(data, textStatus, jqXHR)
        {
            $('#search-results').html(data);
        }
search-results.html

{% for data in datas %}
<tr>
    <td>{{ data.score}}</td>
    <td>{{ data.distance}}</td>
    <td>{{ data.time}}</td>
    {%for element in data.place.elements%}
    <td>       
        {{element.placeName}}
    </td>
    {% endfor %}
    <td>
        <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h3 id="myModalLabel">Share with your friends</h3>
            </div>
            <form action="{% url "send_mail"%}" class="form-horizontal" method="post">
            <div class="control-group">
                <label class="control-label" for="subject">Subject</label>
                <div class="controls">
                    <input type="text" name="subject" value="Your friend has shared a traverse trip" id="subject" placeholder="subject">
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="email">Email</label>
                <div class="controls">
                    <input type="text" name="email" id="email" placeholder="Email">
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="message">Message</label>
                <div class="controls">
                    <input type="text" name="message" id ="message" placeholder="message" value ="Here we will have the link  ">
                </div>
            </div>
            <div class="modal-footer">
                {% csrf_token %}
                <input type="submit" value="email" class="btn btn-primary">
            </div>
            </form></div>
        <a href="#myModal" role="button" class="btn btn-mini" data-toggle="modal"><i class="icon-envelope"></i>SendEmail</a>
        <a href="{% url "add_trip" city=data.score score=data.score distance=data.distance|floatformat:"0" time=data.time %}"
        class ="btn btn-mini btn btn-warning">Add/delete</a>
    </td>
</tr>
{% endfor %}*
4

0 回答 0