模式对话框内的链接不起作用

Links inside modal dialog have no effect

本文关键字:链接 不起作用 对话框 模式      更新时间:2023-09-26

我有两个具有相同链接的区域,我用jquery和handle来获取它们。侧边栏工作正常,但模式对话框不执行任何操作。我对jQuery没有太多经验,我怀疑我的问题就在那里。相关网页如下:

        <div id="sidebar"> 
            Case List:
            <br />
            <a id="add_case" href="#"> New </a>
            <ul>
                {%recursetree nodes %}
                <li>
                    <a class="get_case" data-id="{{node.id}}" href="#">{{node.name}}</a>
                    {%if not node.is_leaf_node %}
                        <ul class="children">
                            {{children}}
                        </ul>
                    {% endif %}
                    </li>
                {% endrecursetree %}
            </ul>
        </div>

    <div id="openFileTree" class="modalDialog">
        <div>
            <a href="#close" title="Close" class="close">X</a>
            <h2>Select:</h2>    
            <ul>
            {%recursetree nodes %}
            <li>
                <a class="get_case" data-id="{{node.id}}" href="#">{{node.name}}</a>
                {%if not node.is_leaf_node %}
                    <ul class="children">
                        {{children}}
                    </ul>
                {% endif %}
                </li>
            {% endrecursetree %}
            </ul>
        </div>
    </div>

相关的javascript在这里:

$('.get_case').click(function(){
var id;
id = $(this).attr("data-id");
$.get('/CLP/case/', {caseId: id}, function(data){
    if(editor == undefined || editor.status == "destroyed")
    {
        $('#primary').html(data.value);
        $('#primary').attr('data-id', id);
    }
    else
    {
        $('#secondary').html(data.value);
        $('#secondary').attr('data-id', id);
    }
});
})

我觉得这是范围或其他方面的疏忽,但我不确定我搞砸了什么

如何在模态窗口中执行 jquery?

以下是正确的格式。

$(document).on("click", ".get_case", function(){...})