【发布时间】:2010-12-04 06:29:00
【问题描述】:
我有一个显示 ExtJS 组件的 django 驱动的网络应用程序。我想显示或隐藏基于一些 django 模板逻辑的 ExtJS 面板。这不起作用,我不知道该怎么做。
这是我尝试过的(字母映射到下面的代码): A. 我试图将模板逻辑放在我的 js 文件中。大失败...这几乎破坏了我的 js。
B.我尝试构建 extjs gui 然后隐藏面板。根据我尝试的方法,我会得到一个 null 或 undefined 错误。我怀疑这里有序列问题,但我不知道如何确认。
基于 django 模板逻辑隐藏/取消隐藏 EXTJS 组件的正确方法是什么?我怎样才能使这项工作?
下面是我的代码sn-ps:
--------------------------
//////////Javascript Start /////////////
//A. Tried to wrap with {% if X %}
var myPanel= {
xtype : 'panel',
title : 'My Panel',
id : 'myPanel',
height : 100,
width : 100,
hideable: true,
html : 'Hello!'
}
///////////Javascript End////////////
<html>
<head>
<!-- references above javascript -->
<script type="text/javascript" src="myfile.js" ></script>
</head>
<body>
... body stuff...
<script type="text/javascript">
<!-- B Tried to a map an EXTJS hide statement with django -->
{% if X %}
Ext.get('myPanel').hide(); // Null Error
Ext.getCmp('myPanel').hide(); // Undefined Error
Ext.getCmp("myPanel").hide(); // Undefined Error
{% endif %}
</script>
</body>
</html>
【问题讨论】:
-
请使用编辑器中的“101010”选项发布代码,当前格式不可读。
标签: javascript django extjs