我是sencha touch 2.0的新手。我有一个html文件。我试图加载这个html文件(或内容)到一个面板。我只是使用ajax调用,但它不起作用。以下是代码。将HTML文件加载到面板中
这是我在浏览器中运行的html文件。
的index.html:
<script type="text/javascript" src="touch/sencha-touch-debug.js"></script>
<script type="text/javascript" src="HTMLPanel.js"></script>
<script type="text/javascript" src="app.js"></script>
这是app.js:
Ext.setup({
name : 'SampleLoad',
requires : ['HTMLPanel'],
launch : function() {
var HTMLPanel = new HTMLPanel({
scroll : 'vertical',
title : 'My HTML Panel',
url : 'sample.html'
});
}
});
,这是HTMLPanel.js:
//HTMLPanel = Ext.extend(Ext.Panel, { //gives error
var HTMLPanel = Ext.define('HTMLPanel',{
extend : 'Ext.Panel',
constructor : function(config) {
HTMLPanel.superclass.constructor.apply(this, arguments);
// load the html file with ajax when the item is
// added to the parent container
this.on(
"activate",
function(panel, container, index) {
if(this.url && (this.url.length > 0))
{
Ext.Ajax.request({
url : this.url,
method : "GET",
success : function(response, request) {
//console.log("success -- response: "+response.responseText);
panel.update(response.responseText);
},
failure : function(response, request) {
//console.log("failed -- response: "+response.responseText);
}
});
}
},
this
)
},
url : null
});
我只想要在面板内显示html内容。有人可以帮忙吗?
我可以确认这是工作,应该接受回答 – roozbubu 2012-08-26 15:31:32