-
17 Mar 2009 1:18 AM #1
ExtJs + Jquery form submit
ExtJs + Jquery form submit
I'm using extjs with jquery and it works fine. But when i submit forms - i get a little problem. The problem is with form serialize function.
if i've text value "just a simple text", after form submit i get "just+a+simple+text". I don't where to post this problem - here or in jquery forums
i get inside jquery and ext-base code and i found this
jquery serialize function, at the end.
how can i submit form without this '+' and using jquery adapter?Code:return s.join("&").replace(/%20/g, "+");
P.S.
i use form.getValues() and Ext.Ajax.request to submit form
-
17 Mar 2009 5:43 AM #2Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,167
- Vote Rating
- 29
how ar eyou seting the textfield's value? Can you see the +'s in the DOM element (via firebug inspection) itself?

Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
17 Mar 2009 10:58 AM #3
I mean not the field value. It is in post request.
For example - textfield named News title. Field settings - name = title, xtype = textfield, allowblank = false. nothing more. Field value is "Just simple text"
In window i've button with handler. I useto get form values.Code:var data = formpanel.getForm().getValues()
And if i debug data variable - i'll have title = "Just+simple+text".
This '+' appears only with jquery adapter.
You can find it at the end of jquery param function
i don't know why they use this code. maybe it is right. but how can i submit my form without this '+'?Code:return s.join("&").replace(/%20/g, "+");
-
6 Dec 2012 12:50 AM #4
Just use native ExtJS form serializer
Just use native ExtJS form serializer
Error happened because of incorrect work of jQuery adapter and his realization of method "Ext.lib.Ajax.serializeForm".
So you need to change implementation of this method to native ExtJS and keep next inclusions order:
Code:1. jquery.js 2. ext-jquery-adapter.js 3. ext-all.js 4. <script type="text/javascript"> Ext.lib.Ajax.serializeForm = function(form) { var fElements = form.elements || (document.forms[form] || Ext.getDom(form)).elements, hasSubmit = false, encoder = encodeURIComponent, name, data = '', type, hasValue; Ext.each(fElements, function(element){ name = element.name; type = element.type; if (!element.disabled && name) { if (/select-(one|multiple)/i.test(type)) { Ext.each(element.options, function(opt){ if (opt.selected) { hasValue = opt.hasAttribute ? opt.hasAttribute('value') : opt.getAttributeNode('value').specified; data += String.format("{0}={1}&", encoder(name), encoder(hasValue ? opt.value : opt.text)); } }); } else if (!(/file|undefined|reset|button/i.test(type))) { if (!(/radio|checkbox/i.test(type) && !element.checked) && !(type == 'submit' && hasSubmit)) { data += encoder(name) + '=' + encoder(element.value) + '&'; hasSubmit = /submit/i.test(type); } } } }); return data.substr(0, data.length - 1); }; </script>


Reply With Quote