-
2 Nov 2011 5:09 AM #1
Unanswered: Form with non ajax and ajax buttons
Unanswered: Form with non ajax and ajax buttons
Hello Can I make a form button with standard Submitting and a few other buttons that will send some data using Ajax?
If it is real tell me, please, how can this be done?
Adding standart submits to the form make that all other buttons also using this method.
-
2 Nov 2011 7:01 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
- Answers
- 3113
you can set standardSubmit on the form and the button to submit in the standard way should work by calling the submit method on the BasicForm. For your Ajax button, you can manually do an Ext.Ajax.request call to send data via Ajax.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
3 Nov 2011 10:08 PM #3
I have already done so, but does not work. this is my code:
firebug writes: Ext.Ajax.Request is not a functionCode:Ext.require([ 'Ext.form.*', 'Ext.loader.*', 'Ext.button.*' ]); Ext.Loader.setConfig({enabled: true}); Ext.Loader.setPath('Ext.ux', '../ux/'); Ext.onReady(function() { function ajaxButtonFunction() { var formdesc = Ext.getCmp('description').getValue(); Ext.Ajax.Request({ url : 'ajax.php' , params : { action : 'getData'}, method: 'POST', success: function ( result, request ) { Ext.MessageBox.alert('Success', 'Data return from the server: '+ result.responseText); } , failure: function () { Ext.MessageBox.alert('Failed', 'Data NOT');} }); } var top = Ext.create('Ext.form.Panel', { renderTo:'order-edit', style: {margin: '0px auto 15px auto'}, frame:true, method: 'POST', url: 'addcom.php', standardSubmit: true, id: 'top', title: 'Some edit', bodyStyle:'padding:5px 5px 0', width: 800, fieldDefaults: { labelAlign: 'top', msgTarget: 'side' }, items: [ { xtype: 'numberfield', fieldLabel: 'Some number', id: 'rate', anchor:'90%' },{ xtype: 'filefield', name: 'sfirstform', fieldLabel: 'Document', labelSeparator: "", labelWidth: 50, msgTarget: 'side', anchor: '80%', buttonText: 'Select file' }, { xtype: 'htmleditor', name: 'description', id: 'description', hideLabel: true, width: 730, height: 120 }, { xtype:'button', text: 'Add comment', name: 'addcomment', handler: ajaxButtonFunction } ], buttons: [{ text: 'Save', handler: function() { var form = top.getForm(); form.submit(); } },{ text: 'Delete' }] }); });
What in my code wrong? How to make correctly? Help me,please!
-
3 Nov 2011 10:25 PM #4
Case senstivity
Case senstivity
Replace 'R'equest by 'r'equest and I think your code should work, that is, use Ext.Ajax.request instead of Ext.Ajax.Request


Reply With Quote