这是我的Ajax功能
Ext.Ajax.request({
url : 'report.php',
method: 'POST',
success: function (result, request ) {
panel.update(result.responseText);
mask.hide();
}
});
我的report.php看起来像这样:
<tr>
<td class='center'><b>Company</b></td>
<td class='center'><b>User</b></td>
<td class='center'><b>Report</b></td>
</tr>
<tr>
<?php foreach ($data as $day) {?>
if($day == $today){
<td onClick="ExtJsFunction()"><?php $today?></td>
}else{
///
}
}
如何在ExtJs代码中编写一个函数,我可以在这里点击调用 我不知道该怎么做。我还没有尝试过任何东西
答案 0 :(得分:2)
我如何在ExtJs代码中编写一个函数,我可以从这里点击进行调用而且我不知道该怎么做。我还没有尝试过任何东西
我认为您可以将singleton用于全局或常用功能。
Singleton 是一个只能有一个对象实例的类。在ExtJS 4或更高版本中,一旦加载了应用程序,就会实例化单例对象。
我创建了一个小sencha fiddle演示希望这会对你有所帮助。
//singleton here is {singleton} class
Ext.define('Gloabal', {
singleton: true,
alternateClassName: 'globalUtilities',
doApiCall: function (el) {
Ext.Msg.alert('Succes','You have clicked on <b>'+el.innerText);
//you can call your api here...
//on basis of your requirment
}
});
Ext.create('Ext.form.Panel', {
title: 'Simple Form',
bodyPadding: 5,
width: 350,
// The form will submit an AJAX request to this URL when submitted
url: 'save-form.php',
// Fields will be arranged vertically, stretched to full width
layout: 'anchor',
defaults: {
anchor: '100%'
},
// The fields
defaultType: 'textfield',
items: [{
fieldLabel: 'First Name',
name: 'first',
allowBlank: false
}, {
fieldLabel: 'Last Name',
name: 'last',
allowBlank: false
}, {
xtype: 'label',
html: '<table style="width: 100%;border-collapse: collapse;text-align: center;cursor: pointer;"><tr>' +
'<td onclick=globalUtilities.doApiCall(this) style="border:1px solid #ccc;">API 1</td>' +
'<td onclick=globalUtilities.doApiCall(this) style="border:1px solid #ccc;">API 2</td>' +
'<td onclick=globalUtilities.doApiCall(this) style="border:1px solid #ccc;">API 3</td>' +
'</tr></table>'
}],
// Reset and Submit buttons
buttons: [{
text: 'Reset',
handler: function () {
this.up('form').getForm().reset();
}
}],
renderTo: Ext.getBody()
});