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.
Code:
return s.join("&").replace(/%20/g, "+");
how can i submit form without this '+' and using jquery adapter?
P.S.
i use form.getValues() and Ext.Ajax.request to submit form
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>