What else can I pass to the `form` property of Ext.Ajax.request?

Normally one posts an ExtJS form to the backend using form.submit({...}). I want to make my form submission synchronous now, so I'm switching to using Ext.Ajax.request({async: false, ...}). The form property of Ext.Ajax.request() usually looks like so:

Ext.Ajax.request({
    url: 'formsubmit',
    form: 'formid',
    method:'POST',
    success: function(response, opts) {
        alert("successfull");
    },
    failure:function(res,opt) {
        alert("request failed");
    }
});

I'm dealing with a bunch of anonymous forms right now. Is there any way around this?

Given a var form = {xtype: 'form', items: [...]} I've tried replacing 'formid' with form.getEl(), form.getForm(), and form.getForm().getFieldValues() which all don't work.

There's no other way around this other than assigning a generated id to each of my anonymous forms, is there.

Thanks for any input

Answers


It looks like the ExtJS forms do not actually use form elements in the markup. When the submit function is called on an ExtJS form, an HTML form element is crafted as part of the process, and that's the form that is used for the submission.

http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.form.action.Submit-method-buildForm

Ideally, you could modify the options that are used in the Ajax request called within the doSubmit function. Since you can't, you might want to consider overriding Ext.form.action.Submit such that you can, then calling the form.submit() function you mentioned in your question.

http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.form.action.Submit-method-doSubmit


It looks like you could just do this as an alternative to the form attribute:

var form = this.down('form');
Ext.Ajax.request({
    url: 'test.xyz',
    params: form.getValues()
    // etc...
});

getValues gives you the name/value pairs you need for your submission.


Need Your Help

Eclipse: High CPU Usage during Autocomplete

eclipse performance autocomplete

I've been using Eclipse without issue (I mean, besides the usual) for several weeks now. It's been speedy enough for my purposes. But as of today around noon, anytime I start typing an HTML tag or ...

SQL Replace instance of word with another

mysql sql

I am trying to search through a table column for: <o:p /> to then replace it to </p>

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.