Hello Alain and everyone :)

I've experimented with doing form submission via JavaScript, and it's
working well for me, *except* that I've made an edit to *xsltforms.js*.  So
I'd like to show my use case, and show the edit I made to the code, and
then get some feedback.

*1. MY USE CASE*

For now, I find it most convenient to handle the submission in JavaScript.
 If submission fails, the server (in my application) will provide a JSON
response containing an exception.  I find it simplest (for now) to handle
the submission request in JavaScript (with jQuery which is running in the
parent document).   Xsltforms provides for doing this, but I ran into a
problem where it was appending url-encoded instance data to the URL, which
wasn't appropriate in my use case.

Here's the submission element from my form:

<xf:submission
    id='submit'
    method='get'
    relevant='true'
    replace='instance'
    serialization='application/xml'
    action='javascript:submit(ser)'
/>


Here you can see the whole top level of my form, which includes the
JavaScript for submission: http://pastebin.com/N2KCAT5t

*2. MY CODE CHANGE*
*
*
At revision 565, my change is to line 4105 of *xsltforms.js* (split onto
multiple lines here)*:*

if ((method === "get" || method === "delete")
    && this.serialization !== "none"
    *&& action.substr(0, 11) !== 'javascript:'*
    && action.substr(0, 9) !== "opener://"
    && action.substr(0, 8) !== "local://") {


The effect of the change is to skip adding the url-encoded arguments, for a
'get' or 'delete' submission where the action is JavaScript.  This way I
can pass XML to my JavaScript submission function, and avoid having the
action mangled to something like 'javascript:submit(ser)*
?var1=val1&var2=val2*'.

*3. YOUR THOUGHTS?*
*
*
Is my change OK to integrate into mainline source?  Or maybe there's a
better way to go?

Thanks very much,

/Adam
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122712
_______________________________________________
Xsltforms-support mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xsltforms-support

Reply via email to