PDA

View Full Version : Using tabPanel to load a page create by yui-ext will not trigger Ext.onReady.(help)


dvdext
05-12-2007, 03:27 PM
I have a tabPanel page, I create a tabPanel like this:


Ext.onReady(function(){
var resumeTabs = new Ext.TabPanel('resumeTabs');
var tab3 = resumeTabs.addTab('baseinfo', "baseinfo");
tab3.setUrl({url:'resume_add_baseinfo.php',scripts:true,text:'load...'}, null, false);

var tab4 = resumeTabs.addTab('resumeTabs-3', 'anme');
tab4.setUrl({url:'password_modify.php',nocache:true,scripts:true,text:'loading...'}, null, false);
resumeTabs.activate('baseinfo');
});


There is a form in resume_add_baseinfo.php created by .js on fly. Of ourse, the js code is wrote in Ext.onReady(function(){....});, I debuged it by firebug, the js code in Ext.onReady( ) is not be executed. It means, when the 'tab3' be clicked , the file 'resume_addbaseinfo.php' will be requested, but the Ext.onReady() will be run, If i put the codes out of onReady(), the js will run . But i got another problem:

the js code will run at first time, when I click tab4 and tab3 several times, will gat a error.
It cannnot work well in IE too.

I have read the html of the tabPanel created, the resume_add_baseinfo.php be embed in a <div> tag, I guess, if the resume_add_baseinfo.php' be load in a iframe , will work well.
Becasue my resume_add_baseinfo.php works verywell in IE or FF but be load by a tabPanel

So How can I render the tabPanelItem to a <iframe> but a <div>
or Who have a good idea to solve it?
or I have to create a normal resume_add_baseinfo.php but use yui-ext to create the form(but i like the widget of yui-ext's form):((

Thanks.
ps, i use the newest verison 1.0.1a

Animal
05-13-2007, 01:33 AM
Using onReady in Ajax-loaded content is pointless. The document is ready. It's been ready since it was loaded!

Scripts in Ajax-loaded content are only evakuated by Ext when that content is fully rendered.

dvdext
05-13-2007, 06:46 AM
Thank you for your help,
I give a <iframe > in TabPanelItem to solve it :)
kludge , but works :">

thanks again!!

Animal
05-13-2007, 01:54 PM
Why not debug it properly? Scripts do get evaluated when loaded. You were doing something wrong, but just gave up trying to find out what.

ssgemail@126.com
07-09-2007, 10:56 PM
I not use iFrame in the tabItem

I trim Ext.onReady in js file like the following
var fs_addContract;

//Ext.onReady(function(){
alert("Hello World");
// Ext.QuickTips.init();

// turn on validation errors beside the field globally
//Ext.form.Field.prototype.msgTarget = 'side';

/*
* ================ Form 3 =======================
*/
fs_addContract = new Ext.form.Form({
baseParams: {id: 'addContractForm'},
labelAlign: 'right',
labelWidth: 90
});

fs_addContract.fieldset(
{legend:''},
new Ext.form.TextField({
fieldLabel: '合同编号',
name: 'contractNum',
width:190,
blankText: '不能为空',
allowBlank:false
}),
new Ext.form.TextField({
fieldLabel: '甲方',
name: 'companyName',
width:190,
blankText: '不能为空',
allowBlank:false
}),

new Ext.form.TextField({
fieldLabel: '签订数量',
name: 'signsNumber',
width:190
}),

new Ext.form.TextField({
fieldLabel: '服务费总额',
name: 'payTotals',
width:190
}),

new Ext.form.TextField({
fieldLabel: '合同签订人',
name: 'signsPerson',
//vtype:'signsPerson',
width:190
}),

new Ext.form.TextField({
fieldLabel: '合同有效期',
name: 'contractEffective',
//vtype:'contractEffective',
width:190
}),
new Ext.form.ComboBox({
fieldLabel: '下拉列表',
hiddenName:'state',
store: new Ext.data.SimpleStore({
fields: ['abbr', 'state'],
data : Ext.exampledata.states // from states.js
}),
displayField:'state',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'请选择...',
selectOnFocus:true,
width:190
}),
new Ext.form.DateField({
fieldLabel: '合同签订日期',
name: 'signsDate',
format: 'Y-m-d',
width:190,
allowBlank:true
}),
new Ext.form.DateField({
fieldLabel: '合同到期日期',
name: 'dueDate',
format: 'Y-m-d',
width:190,
allowBlank:true
}),
new Ext.form.TextField({
fieldLabel: '实际入网数量',
name: 'actualNumber',
//vtype:'actualNumber',
width:190
}),

new Ext.form.TextField({
fieldLabel: '实交服务费',
name: 'actualServiceFee',
//vtype:'actualServiceFee',
width:190
}),

new Ext.form.TextField({
fieldLabel: '甲方公司电话',
name: 'companyTel',
//vtype:'companyTel',
width:190
}),

new Ext.form.TextField({
fieldLabel: '甲方公司联系人',
name: 'companyPerson',
//vtype:'companyPerson',
width:190
})
);

var submit = fs_addContract.addButton({
text: '更新',
disabled:false,
handler: function(){
fs_addContract.submit({url:'/updateContract.do', waitMsg:'请稍后...'});
}
});
var submit = fs_addContract.addButton({
text: '添加',
disabled:false,
handler: function(){
fs_addContract.submit({url:'/addContract.do', waitMsg:'请稍后...'});
}
});
var reset = fs_addContract.addButton({
text: '重置',
disabled:false,
handler: function(){
fs_addContract.reset();
}
});

fs_addContract.render('form-addone-contract');
fs_addContract.on({
actioncomplete: function(form, action){
if (action.failureType == 'server'){
var errors = action.result.errors;
Ext.Msg.alert('服务器端异常信息', 'id:' + action.result.errors.id + ' - msg:' + action.result.errors.msg);
}else{
Ext.MessageBox.alert('提示', '提交成功');
}

if (ds_contract){
ds_contract.reload();
Ext.Msg.alert('提示','数据已刷新');
}
}
});
fs_addContract.on({
actionfailed: function(form, action){
if (action.failureType == 'client'){
Ext.MessageBox.alert('客户端异常信息', '验证出现问题');
}

if (action.failureType == 'server'){
var errors = action.result.errors;
Ext.Msg.alert('服务器端异常信息', 'id:' + action.result.errors.id + ' - msg:' + action.result.errors.msg);
}

}
});
//});


when open the tabItem in IE, the status bar show the exception: Ext.EventObject is null or not object

please help me.
3ku first!

ssgemail@126.com
07-09-2007, 11:05 PM
In FireBug , the errors is
Ext.EventObject has no properties
http://192.168.1.10/billing/ext-all-debug.js
Line 1523

Animal
07-10-2007, 02:20 AM
What js files ae you including in the main page?

ssgemail@126.com
07-10-2007, 02:42 AM
In the main page , include the following js file

<script type="text/javascript" src="../adapter/yui/yui-utilities.js"></script>
<script type="text/javascript" src="../adapter/yui/ext-yui-adapter.js"></script>
<script type="text/javascript" src="../ext-all-debug.js"></script>

<script type="text/javascript" src="js/main.js"></script>
<script type="text/javascript" src="js/menu.js"></script>
<script type="text/javascript" src="js/ext-lang-zh_CN.js"></script>