1

我的网站上有两个框架。带有导航栏的框架 A 和带有主要内容的另一个框架 B。

框架 A 是一个目录列表,一个 jstree 对象,它可以显示我计算机中所有文件的名称。

当我在框架 A 中单击时,框架 B 会显示文件的内容。同时,当我单击文件夹时,框架 A 中的文件夹会扩展。也就是说,当我在框架 A 中单击时会有两个事件(如果它是一个文件夹,我会在框架 A 中扩展文件夹,并且只在框架 B 中显示文件夹的路径)。

现在,我可以扩展文件夹,但是当我单击框架 A 中的文件名时,框架 B 不显示文件的内容。如果我想在框架 B 中显示文件的内容,我应该怎么做?

框架 B 中的页面是 django 形式:

class FileForm(forms.Form):
    path = forms.CharField(max_length = 300, label = u"file path", help_text = u"file full path", error_messages = {"required" : ""})
    text = forms.CharField(max_length = 300, widget = forms.Textarea, label = u"file text", help_text = u"file content", error_messages = {"required" : ""})

当我单击框架 A 中的文件名时,我可以使用此表单生成一个 html:

def get_render_conf_text_info(request):
    if request.method == "POST":
        tmp_file_text = ""
        tmp_file_path = ""
        ....
        tmp_form = FileForm(initial = {'path' : tmp_file_path, 'text' : tmp_file_text})
        return render_to_response('conf_nav_right2.html', {'form' : tmp_form}, context_instance=RequestContext(request))
    else:
        tmp_form = FileForm(initial = {'path' : '', 'text' : ''})
        return render_to_response('conf_nav_right2.html', {'form' : tmp_form}, context_instance=RequestContext(request))

框架 A 中的 html 代码(使用 jstree.js):

<ul>
<li id="file_0_a1.cfg" class="0 jstree-close jstree-leaf" value="0" rel="file">
    <ins class="jstree-icon">&nbsp;</ins>
    <a href="#" class="jstree-clicked" target="conf_nav_right">
        <ins class="jstree-icon">&nbsp;</ins>
        a1.cfg
    </a>
</li>
<li id="folder_1_remote" class="1 jstree-close jstree-leaf" value="0" rel="folder">
    <ins class="jstree-icon">&nbsp;</ins>
    <a href="#" class="">
        <ins class="jstree-icon">&nbsp;</ins>
        remote
    </a>
</li>
</ul>

conf_nav_right ” 是框架 B 的名称。

任何帮助,将不胜感激!

4

1 回答 1

0

我终于解决了这个问题,只需在 htmldocument 中使用函数 write() 即可。

如果你也遇到这个问题,试试吧。

于 2013-05-26T07:13:14.620 回答