Open hawkxu opened 7 years ago
You can already modify the postData before sending in the onSubmit event.
You can also modify the received data before it is parsed in the onLoad event (you will have to modify the xhr
object).
Please close the issue if this answers your question.
Cheers =)
I know about that I can do this through event handler, but I want to do some common process for all form, this need to extend from w2form (like w2obj.form.preparePostData = ....), and then do some special process for various form through event handler.
BTW: I'm building a library (taglib) to make JSP and W2UI integration a little easier, so I can not use event handler to solve my requirements.
thanks
I want to use W2UI with JSP pages with struts2 framework, the struts2 json plugin accept data format like this: {'username': 'test', 'password': 'secret'}, and W2UI library currently use format like: {'recid': 0, 'cmd': 'save-record', 'record': {'username': 'test', 'password': 'secret'}, ...}, so, I think about to add a method like
//build params in preparePostData method var params = obj.preparePostData(postData);
and before trigger after save event, add a method like data = obj.parseResponseData(data); // event after obj.trigger($.extend(eventData, { phase: 'after' }));
in additional, beacause the response data may be contains no status field, so check data.status not equal to error instead of equal to success if (data.status != 'error' && typeof callBack == 'function') callBack(data);
thanks and sorry for my poor English